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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 829 views
  • 0 likes
  • 2 in conversation