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
Diamond | Level 26
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]

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