BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a proc report that uses a spanning header over multiple columns. I need to vary the contents of the spanning header based on a variable. is this possible?

JK
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
This is not directly possible unless you use a SAS Macro Program. Your other alternative is to use BY group processing in PROC REPORT and then to use #BYVAR/#BYVAL in the Title statement for Proc Report -- I know this isn't in the spanning header -- but it may be close to what you want. There's an example of a small SAS macro program with variable information in the spanning header program below. The PROC REPORT isn't very complicated...but it does show overridding the value of a header. You could make the macro logic as complicated as it needed to be.

cynthia
[pre]

%macro myhdr(reg=, prod=, hdtxt= );
%if ® = Asia %then %let hdtxt = Something Else;

proc report data=sashelp.shoes(obs=20) nowd;
where Region = "®" and product = "∏";
column region ("&hdtxt" region product sales );
run;
%mend myhdr;

ods listing close;
ods html file='c:\temp\myhdr.html' style=sasweb;
%myhdr(reg=Africa, prod=Sandal, hdtxt=African Sandals);
%myhdr(reg=Asia, prod=Boot, hdtxt=Asian Boots);
%myhdr(reg=Canada, prod=Slipper, hdtxt=Canadian Slippers);
ods html close;
[/pre]

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
  • 1 reply
  • 843 views
  • 0 likes
  • 2 in conversation