Parsing header line separately in SAS

夙愿已清 提交于 2019-12-05 20:20:17

You are mixing up data step variables and macro variables. You can't conditionally execute a %LET statement like that (and you don't want to). CALL SYMPUT is how you'd create a macro variable, if you wanted to; but in this case you don't, as you can perform this all in one data step:

data want;
informat fdate sdate YYMMDD8.;
retain Agency Status Num fdate sdate;
if _n_ = 1 then do;
  input Agency $ Status $ Num $ fdate sdate;
end;
else do;
    if fdate < '28APR2013'd then input
       @1   poolno                  $6.
       @7   factor                  9.8;
    else
     input
       @3   poolno                  $6.
       @9   factor                  9.8;

    output;
end;
datalines;
MyAgency MyStatus MyNum 20130401 20130501
MyPool123456783123
MyPoo2435678904123
;;;;
run;

Now, one thing to note - You normally don't add the decimal to the informat (ie, @9 factor 9.8) unless you have a number that has no decimal and you want to add it. IE, in the data I created, I did not have a decimal (123456783) and it will add one (1.23456783). However, if the decimal is already in the data, ie 1.23456783 is in your data file, then you should just input it as 9. and let SAS place the decimal for you. Also, if you test this make sure to move the datalines over to the first column (indenting them 4 will cause this to fail).

Also, you need to learn how to work with SAS dates - see how I changed it slightly.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!