BookmarkSubscribeRSS Feed
Minaxi_Patel
Calcite | Level 5


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.

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

data _null_;

     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;');

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.

Minaxi_Patel
Calcite | Level 5

I can't change my report format as per your suggetion.Smiley Sad

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1572 views
  • 0 likes
  • 2 in conversation