【SAS NOTES】array+do to

array的好处是可以通过循环来对变量进行操作。

do to sas语句中对于循环的控制。

data mysas.ifthen7;
    infile 'e:\ifthen.txt' dlm='09'x firstobs=2;
    input date yymmn6. gtone shen dong all;
    array sms(4) gtone shen dong all;
    do i=1 to 4;
        if YEAR(date)=2009 then sms(i)=sms(i)*10;
    end;
run;
proc print data=mysas.ifthen7;
run;
data mysas.ifthen6;
    infile 'e:\ifthen.txt' dlm='09'x firstobs=2;
    input date yymmn6. gtone shen dong all;
    if YEAR(date)=2009 then all=all*100;
run;

1、do 后面不要忘记end

2、year等函数可以用来处理日期,所以把日期导入成日期格式有很大好处。

原文地址:https://www.cnblogs.com/colipso/p/2875278.html