Help using Base SAS procedures

Change proc report header for certain columns

Accepted Solution Solved
Reply
Contributor
Posts: 57
Accepted Solution

Change proc report header for certain columns

I have a SAS dataset that I created using a proc sql full outer join statement from table A and table B.  The resulting table contains 5 columns/variables from table A and 3 columns/variables from table B.  Now, I'd like to simply dump out these columns of raw data in a proc report with the variable lables as headers, but over the first 5 columns I'd like a header panel (like an across varible) to read "Dataset A" and across the top of the next 3 columns, I'd like to see a header panel that reads "Dataset B."  Is there a good way to do this?

PS.  I'm open to using other procedures too if this is easier in something like proc tabulate (or proc print even since I'm just dumping the contents of the dataset and not summarizing the data).


Accepted Solutions
Solution
‎09-06-2016 03:58 PM
Occasional Contributor
Posts: 18

Re: Change proc report header for certain columns

Hi there,

 

I believe that the following code will solve what you are looking for.

 

data test;
input a b c d e x $ y $ z $;
datalines;
1 3 4 0 1 no yes no
2 1 5 3 5 yes yes no
3 2 6 4 3 no no no
4 2 9 5 2 no no yes
5 1 3 9 7 no yes no
6 2 4 2 8 yes yes yes
7 3 4 8 4 no no no
;
run;

proc report data = test missing;
column ("Dataset 1 " a b c d e) ("Dataset 2" x y z);
define a / group;
define b / group;
define c / group;
define d / group;
define e / group;
define x / group;
define y / group;
define z / group;
run;

Capture.PNG

View solution in original post


All Replies
Solution
‎09-06-2016 03:58 PM
Occasional Contributor
Posts: 18

Re: Change proc report header for certain columns

Hi there,

 

I believe that the following code will solve what you are looking for.

 

data test;
input a b c d e x $ y $ z $;
datalines;
1 3 4 0 1 no yes no
2 1 5 3 5 yes yes no
3 2 6 4 3 no no no
4 2 9 5 2 no no yes
5 1 3 9 7 no yes no
6 2 4 2 8 yes yes yes
7 3 4 8 4 no no no
;
run;

proc report data = test missing;
column ("Dataset 1 " a b c d e) ("Dataset 2" x y z);
define a / group;
define b / group;
define c / group;
define d / group;
define e / group;
define x / group;
define y / group;
define z / group;
run;

Capture.PNG

Contributor
Posts: 57

Re: Change proc report header for certain columns

PERFECT!!!!!  I had no idea you could do that (or maybe i did at one time, but forgot).  Thanks so much for this.  I really appreciate your taking the time to help!

Contributor
Posts: 57

Re: Change proc report header for certain columns

One follow-up question to this.  Do you know how to gain control over the styling of the top panel ("Dataset 1" and "Dataset 2")?  I have no problem applying styles to the columns and headers, but can't seem to figure out how to get control over the top panels?

Occasional Contributor
Posts: 18

Re: Change proc report header for certain columns

[ Edited ]

You can use the ods escapechar to change the style of the headers. I would also look into this paper on the different options with escapechar that you can use: http://www2.sas.com/proceedings/forum2007/099-2007.pdf.

 

ods escapechar = "#";
proc report data = test missing;
column ("#S={fontsize=8pt font_face=courier font_weight=bold color=red}Dataset 1 " a b c d e) 
("#S={fontstyle=italic}Dataset 2" x y z); define a / group; define b / group; define c / group; define d / group; define e / group; define x / group; define y / group; define z / group; run;

Capture3.PNG

 

 

 

Contributor
Posts: 57

Re: Change proc report header for certain columns

A million thanks to you!!!  This is just what I needed.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 602 views
  • 2 likes
  • 2 in conversation