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).
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;
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;
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!
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?
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;
A million thanks to you!!! This is just what I needed.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.