BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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).

1 ACCEPTED SOLUTION

Accepted Solutions
howarder
Obsidian | Level 7

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

5 REPLIES 5
howarder
Obsidian | Level 7

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

statistician13
Quartz | Level 8

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!

statistician13
Quartz | Level 8

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?

howarder
Obsidian | Level 7

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

 

 

 

statistician13
Quartz | Level 8

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 4601 views
  • 2 likes
  • 2 in conversation