12-02-2014 07:04 AM
Hi, I am going to generate one report using proc report and report will run once in a week and generate one more additional column . I want to automise this code using %do Loop or something else but don't know how to do it?
Please find the attach code. It is just 1/10 size of the original proc report code.
12-02-2014 08:23 AM
And what happens when there is not enough width on the page to fit all your columns in? My suggestion would be not to do it this way. What you are talking about is normalized data, i.e. fixed number of columns with the data going down the page. So set your data up such:
flg stat commercial period value
X XXX XXXX 05JAN14 XXX
X XXX XXXX 12JAN14 XXX
And then you have the abilty to list any amount of data down the page, fix your proc report so no updating each time. That would be my suggestion. If you don't want to follow it then you open a whole world of pain for yourself. The actual code generation part is pretty straight-forward:
set sashelp.vcolumn (where=(libname="XYZ" and memname="DSNAME") in=a)
sashelp.vcolumn (where=(libname="XYZ" and memname="DSNAME") in=b) end=last /* one for column statement, one for define */;
if _n_=1 then call execute('proc report data=... options...; column ');
if a then call execute(' '||name);
else call execute(' define '||name||' / display noprint;');
if last then call execute(' compute statements; run;');
However your main problem is going to be layout, data which doesn't conform to what you expect, page breaking in unusual places etc.