The SAS Output Delivery System and reporting techniques

Variables in a Spanning Header

Reply
N/A
Posts: 0

Variables in a Spanning Header

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
SAS Super FREQ
Posts: 8,868

Re: Variables in a Spanning Header

Posted in reply to deleted_user
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]
Ask a Question
Discussion stats
  • 1 reply
  • 141 views
  • 0 likes
  • 2 in conversation