我发的所有命令我都在sas9.1运行过了,都可以运行哦~放心用吧!
/* sas有各种语言,与其他编程语言一样,都有输出语句,也有条件语句和循环语句及赋值语句*/
proc print data=sasuser.wage; /* 打印 */
var wage sex race;
run;
data aa;
set sasuser.wage;
if sex=1 then delete; /* 条件语句*/
run;
data bb;
input x y z@@;
if x>=20 then class=1; /* 条件语句*/
else class=2;
cards;
15 26 5 1328 32 18 35 12 30 30 20
;
run;
Data cc;
Do n = "n1","n2","n3","n4","n5" ;
Do w =" 1","2","3"; /* 循环语句 */
Input y @@;
output;
End;
end; /* 循环语句结束语句*/
Cards;
90.53 88.4347.37 175.8 100.0190.53 88.43 47.37 175.8 100.0190.53 88.43 47.37 175.8100.0190.53 88.43 47.37 175.8 100.01 142.12 163.17 63.16 166.33 144.75 142.12 163.17 63.16 166.33 144.75 142.12 163.17 63.16 166.33 144.75 142.12 163.17 63.16 166.33 144.75 87.3887.3887.3887.38 65.27 68.43 210.54 194.7565.27 68.43 210.54194.7565.27 68.43 210.54 194.7565.27 68.
43 210.54194.75
;
run;
data dd;/*循环语句*/
Interest = .0375;
Total = 100;
do Year = 1 to 3;
Total + Interest*Total;
output;
end;
format Total dollar10.2; /*格式语句*/
run;
data ee;/*循环语句*/
do i=1 to 20 by 2;
j=i**3;
output;
end;
run;
title 'invest'; /*输出窗口的主题为'invest'*/
data ff;
do year=1 to 10 until (capital>50000); /*循环语句*/
capital+4000;
capital+(capital*0.1);
output; /*强制输出一条记录'*/
format capital dollar12.2;
end;
proc print data=ff noobs;
format capital dollar12.2;
run;
data gg;
do year=1 to 20; /*循环语句*/
capital+2000;
do mouth=1 to 12;
i=capital*(0.075/12);
capital+i;
end;
end;
run;
data leave_it; /*运用到leave跳出循环的循环语句*/
Interest = .0375;
Total = 100;
do Year = 1 to 100;
Total = Total + Interest*Total;
output;
ifTotal ge 200 then leave;
end;
format Total dollar10.2;
run;
data continue_on; /*运用到continue跳出本次循环下次循环的语句,进入的循环语句*/
Interest = .0375;
Total = 100;
do Year = 1 to 100 until (Total ge 200);
Total = Total + Interest*Total;
if Total le 150 then continue;
output;
end;
format Total dollar10.2;
run;
大家加油哦~~