BookmarkSubscribeRSS Feed
Phil_NZ
Barite | Level 11

Hi SAS Users,

 

I have three dataset called "winsorize_sample", "treatment_sample", and "control_sample". Now I want to build a Table including the summary statistic of all numeric variables of these three datasets together.

In particular, these three datasets haves the same variables, among them, Type, Ename, geogn, year, acc_sta are character variables while acc_pay, ACC_PAY_TURN, and LAGS18 are numeric variables. For all three datasets, I want to summarize all numeric variables except LAGS18.

I also attached the sample of these three datasets in this post.

A quick description of the dataset

 

TYPE	ENAME	    GEOGN	    YEAR	acc_pay	ACC_PAY_TUR	    ACC_STA	         LAGS18
134495	DYCASA 'B'	ARGENTINA	1994	7445	.	            Local standards	 .
134495	DYCASA 'B'	ARGENTINA	1995	10099	8.7216142271	                 .
134495	DYCASA 'B'	ARGENTINA	1996	6277	8.0189301417	Local standards  2.57
134495	DYCASA 'B'	ARGENTINA	1997	8419	11.732035928	Local standards	 2.01
134495	DYCASA 'B'	ARGENTINA	1998	15387	7.5126438713	Local standards  5.91
134495	DYCASA 'B'	ARGENTINA	1999	18653	4.833666275  	Local standards	 3.87

Now, I want to have a summary statistic Table like below( I make it by using Excel), can you please let me know how to make a Table like that in SAS.

 

My97_1-1612865084544.png

 

 

Many thanks in advance and warm regards!

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
2 REPLIES 2
Shmuel
Garnet | Level 18

First step will be to concatenate the 3 datasets and adding the dataset name in a variable as shown in next example code:

data a; x=1;
data b; x=2;
data c; x=3; run;
data all;
 set a b c :indsname=dsn;
  length dsname $32;
  dsname = scan(dsn,2);
  keep x dsname; /* adapt to keep all and only required variables to the report */
run;

Step-2 will be to run PROC MEANS and create a summary table

by dsname (the new added variable) ACC_PAY ACC_PAY_TURN;

VAR <numeric analytic variable/s>;

OUTPUT out=<summed dataset name> <statistics required>;

 

Step-3 will be to transpose the table getting the statistic variable name into a new variable

that can be renamed or assigned as "Summary" for the summary column in the report.

 

Last step - use PROC TABULATE to create the report.

 

Try to create the code and run it. If you have any issue post the code and the log.

Reeza
Super User
1. Either summarize each data set separately and merge the results
2. Combine the datasets together, use PROC TRANSPOSE to restructure the data so you have one variable for winsorized, treatment and control values. Then use PROC TABULATE to create a nice formatted table.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 529 views
  • 2 likes
  • 3 in conversation