'documentation on the data: ' https://s3.amazonaws.com/files.fred.stlouisfed.org/fred-md/Appendix_Tables_Update.pdf close @wf 'get the latest data (monthly only) wfopen https://s3.amazonaws.com/files.fred.stlouisfed.org/fred-md/monthly/current.csv colhead=2 namepos=firstatt pagecontract if sasdate<>na pagestruct @date(sasdate) 'perform transformations %serlist = @wlookup("*", "series") for %j {%serlist} %tform = {%j}.@attr("Transform:") if @len(%tform) then if %tform="1" then series temp = {%j} 'no transform endif if %tform="2" then series temp = d({%j}) 'first difference endif if %tform="3" then series temp = d({%j},2) 'second difference endif if %tform="4" then series temp = log({%j}) 'log endif if %tform= "5" then series temp = dlog({%j}) 'log difference endif if %tform= "6" then series temp = dlog({%j},2) 'log second difference endif if %tform= "7" then series temp = d({%j}/{%j}(-1) -1) 'whatever endif {%j} = temp {%j}.clearhistory d temp endif next group grp * grp.drop resid grp.drop sasdate for !i=1 to grp.@count %name = grp.@seriesname(!i) next smpl 1960:03 @last 'impute missing values with mean of non-missing observations for !k=1 to grp.count 'compute mean of non-missing observations series tmp = grp(!k) !mu = @mean(tmp) 'set missing observations to mean smpl if grp(!k)=NA grp(!k)=!mu 'clean up before next series smpl 1960:03 @last d tmp next