SAS编程技术数据步循环与转移控制.pptVIP

  • 1
  • 0
  • 约6.56千字
  • 约 92页
  • 2026-01-08 发布于江西
  • 举报

第8章数据步循环与转移控制;DO语句;简单DO语句;应用举例;329dataa;

330setfdata.class;

331ifage14thendo;

332h_cm=30.5*height/12;

333putname=sex=age=h_cm=;

334end;

335run;

Name=JanetSex=FAge=15h_cm=158Name=MarySex=FAge=15h_cm=169Name=PhilipSex=MAge=16h_cm=183

Name=RonaldSex=MAge=15h_cm=170Name=WilliamSex=MAge=15h_cm=169NOTE:从数据集FDATA.CLASS读取了19个观测。

NOTE:数据集WORK.A有19个观测和6个变量。

NOTE:“DATA语句”所用时间(总处理时间):

实际时间0.01秒

CPU时间0.01秒;循环DO语句;SPECIFICATION选项格式;例8.4使用表达式选项。

doi=1to10while(xy);

doi=2to20by2until((x/3)y);

doi=10to0by–1while(month=jan);;应用举例;336dataa;

337inputxy;

338ifxythengotoskip;/*skip是循环体外的语句标号*/

339y=log(y-x);

340yy=y-20;

341skip:ify0thendo;

342putx=y=;

343z=log(x-y);

344end;

345cards;

x=5y=-1

NOTE:数据集WORK.A有3个观测和4个变量。

NOTE:“DATA语句”所用时间(总处理时间):

实际时间0.04秒

CPU时间0.01秒

349;

350run;;例8.6产生指定观测值个数的数据集。

dataa;

don=1to100;

output;

end;

run;

例中,产生一个含有100个观测值的数据集。;例8.7自然数求和。

dataa;

t=0;

don=1to100;

t=t+n;

output;

end;

run;

例中,求1到100的自然数之和。;例8.9用循环DO语句处理数组。

arrayday{7}d1-d7;/*定义数组day{7}*/

doi=1to7;

ifday{i}=99thenday{i}=100;

end;

例中,用循环DO语句处理数组时,便于进行批量更新。;DOOVER语句;应用举例;DOWHILE语句;应用举例;DOUNTIL语句;应用举例;END语句;应用举例;SELECT语句;应用举例;例8.14没有SELECT表达式的SELECT语句。

data_null_;

domon=jan,feb,mar,apr,may,jun,jul,aug,sep;

select;

when(monin(jun,jul,aug))putsummermon=;

when(monin(mar,apr,may))putspringmon=;

otherwiseputfallorwintermon=;

end;

end;

run;;361data_null_;

362domon=jan,feb,mar,apr,may,jun,jul,aug,sep;

363select;

364when(monin(jun,jul,aug))putsummermon=;

365when(monin(mar,apr,may))putspringmon=;

366otherwiseputfallorwintermon=;

367end;

368end;

369run;

fallorwintermon=jan

fallorwintermon=feb

springmon=mar

springmon=apr

springmon=may

summermon=jun

summermon=jul

summermon

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档