BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmardinian
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

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

View solution in original post

4 REPLIES 4
Cynthia_sas
Diamond | Level 26

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

kmardinian
Quartz | Level 8

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;

 

Cynthia_sas
Diamond | Level 26
Hi:
I suggest you run my code first. Did my code run for you? Note that I used PROC SQL to create &bign. If you did not create a macro variable called bign, then you should see a message in the log something like this:
WARNING: Apparent symbolic reference BIGN not resolved.

That means you either need to create the macro variable:
1) with a %LET statement
2) in a DATA step program with a CALL SYMPUT or CALL SYMPUTX
3) in a PROC SQL step with INTO as shown in my example.

How did you create &bign???

Cynthia
kmardinian
Quartz | Level 8

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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 7859 views
  • 0 likes
  • 2 in conversation