BookmarkSubscribeRSS Feed
ellpap
Calcite | Level 5

Hi,

I am trying to make a table similar to this one below with the data I have attached. I cannot seem to figure out how to use proc freq to generate the frequencies, proc means ( or proc univariate ) to generate the statistics values and then combine them in this way into a table. If anyone could give me any pointers on how to start that would be awesome! thanks so much!

ellpap_0-1619908560327.png

ellpap_0-1619908798312.png

 

Also these are the assumptions: 

Treatment:

1 = Active
0 = Placebo

Gender:
1 = Male
2 = Female

Race
1 = White
2 = Black
3 = Other

2 REPLIES 2
joseenrique1
SAS Employee

Hi,

 

You can create a table for each purpose using PROC FREQ and PROC MEANS, and then join them with PROC SQL. You also need to create formats. 

 


* I have the data set adsl in this path;
libname a  "C:\Users\jenri\Downloads";

* 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;

Captura de pantalla 2021-05-01 204245.png

 

I hope this is useful for you.

 

 

ellpap
Calcite | Level 5

This is super helpful! How would you then combine them using PROC SQL? 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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