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.
Many thanks in advance and warm regards!
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.