Hi, I am trying to create a report with specific headers. And earlier in my code I had created a variable called bigN that stored the frequencies in each group. I wanted to know whether there was a possibility in Proc Report to add that variable as a header along with the name of the treatment group. I have this so far, I am only trying it for column 1 but it isn't working correctly. Any advice is appreciated! Thank you!
proc report nowd center spanrows missing split='^' data=all list out=test
style(report)=[frame=void rules=none cellspacing=0 padding=1pt font=('Courier New', 8pt)]
style(header)=[bordertopcolor=balck bordertopwidth=1
borderbottomcolor=black borderbottomwidth=1
background=white font=('Courier New', 8pt) textalign=c ]
style(column)=[font=('Courier New', 8pt) ASIS=ON ] ;
columns _PB_page vorder roworder rowlabel col_1 col_2 col_3 col_4;
define _PB_page/group noprint;
define vorder/order noprint;
define roworder/order noprint;
define rowlabel/display id ' ' style(column)=[width=3in] flow;
define col_1/display 'Group 1 (N = ',bign,')' style(column)=[width=1.5in] center flow;
define col_2/display style(column)=[width=1.5in] center flow;
define col_3/display style(column)=[width=1.5in] center flow;
define col_4/display style(column)=[width=1.5in] center flow;
Hi:
If you make &bign (as a macro variable), then you can use "Group 1 (N=&bign)" -- note the use of double quotes, not single quotes. If BIGN is a variable in your dataset, you can't use it in the column header, but look at this example:
proc sql noprint;
select count(name) into :bign
from sashelp.class;
quit;
%put &=bign;
proc report data=sashelp.class;
column ("Class Count (N = &bign)" age sex height);
define age / group;
define sex / group;
define height / mean 'Avg Height' f=7.2;
run;
Also, FLOW is a LISTING-only option, so I'm not sure what your desired ODS output is, but FLOW is going to be ignored here.
Cynthia
Hi:
If you make &bign (as a macro variable), then you can use "Group 1 (N=&bign)" -- note the use of double quotes, not single quotes. If BIGN is a variable in your dataset, you can't use it in the column header, but look at this example:
proc sql noprint;
select count(name) into :bign
from sashelp.class;
quit;
%put &=bign;
proc report data=sashelp.class;
column ("Class Count (N = &bign)" age sex height);
define age / group;
define sex / group;
define height / mean 'Avg Height' f=7.2;
run;
Also, FLOW is a LISTING-only option, so I'm not sure what your desired ODS output is, but FLOW is going to be ignored here.
Cynthia
Hi Cynthia, Thank you so much for your help.
I tried this below code, but it does not seem to register that bigN is a macro variable and only prints "&bigN" as the column header
columns _PB_page vorder roworder rowlabel ("X (N=&bigN)" col_1) col_2 col_3 col_4;
Thank you, Cynthia, I was able to get it to work by creating a macro variable for it, using % let. Thank you for all your help!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.