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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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