BookmarkSubscribeRSS Feed
ellpap
Calcite | Level 5

hi! 

I am trying to combine all my calculations into a table and format it to look like the image below. 

here is the code:

* I have the data set adsl in this path;
libname a  "/folders/myfolders/FinalProject";
 
* Defining formats;
proc format lib=work;
value gender
1 = Male
2 = Female
;
value race 
1 = White
2 = Black
3 = Other
;
value treatment
1 = Active
0 = Placebo
;
run;
 
* Applying formats to the data set ;
proc datasets lib=a;
modify adsl;
format gender gender. race race. trt treatment.;
quit;
 
* Sorting by treatment;
proc sort data=a.adsl out=a.adsl;
by trt;
run;
 
* Statistics ;
proc means data=a.adsl n mean std min max;
by trt;
var age;
output out=work.means1;
run;
 
proc means data=a.adsl n mean std min max;
var age;
output out=work.means2;
run;
 
* Frequencies;
proc freq data=a.adsl;
table trt*gender/out=work.freq1 nocol nopercent;
run;
 
proc freq data=a.adsl;
table gender/out=work.freq2 ;
run;
 
proc freq data=a.adsl;
table trt*race/out=work.freq3 nocol nopercent;
run;
 
proc freq data=a.adsl;
table race/out=work.freq4 ;
run;

 

and here is what I want it to look like:

ellpap_0-1620072057115.png

I have also attached the dataset that is used in the code. Thank you so much!

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Please provide your data as code (data step or SQL create/insert). Many of us will not download files.

 

It looks like you have to concatenate all the outputs as data sets in the layout you want, and then simply use proc print.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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