I wish to use ODS Table Name Output within Proc Means to construct an output data set that contains
( For Example ) the following columns:
Variable_Name, Var_Min, Var_Median, Var_Max, Var_Mean
Var_01 Var_01_Min Var_01_Median Var_01_Max Var_01_Mean
Var_02 Var_02_Min Var_02_Median Var_02_Max Var_02_Mean
Var_60 Var_60_Min Var_60_Median Var_60_Max Var_60_Mean
Ultimately I wish to merge several such SAS Data Sets generated by Proc Means to construct the following Data Set:
Variable_Name Y_Variable, Var_X1_Median, Var_X2_Median, Var_X3_Median
where the Y-Variable may be dependent on one or more of the X variables
I constructed the base data set as follows:
PROC FREQ
DATA = WORK.DATA2SS NLEVELS ;
TABLES SQ01 - SQ59 / NOCOL ;
ODS OUTPUT NLEVELS = WORK.QUESTLEVELS_1 ;
RUN;
So my Data set should contain:
SQ01 Y01=NLEVELS01 X101 X201 X301
SQ02 Y02=NLEVELS02 X102 X202 X302
SQ59 Y59=NLEVELS59 X159 X259 X359
RTM.
Use STACKODS option and ODS OUTPUT.
proc means data=sashelp.class stackods;
ods output summary=want;
run;
proc print data=want;
run;
RTM.
Use STACKODS option and ODS OUTPUT.
proc means data=sashelp.class stackods;
ods output summary=want;
run;
proc print data=want;
run;
In addition to PROC MEANS, you might want to look at the OUTTABLE= option in PROC UNIVARIATE. See the article
"Save descriptive statistics for multiple variables in a SAS data set"
What a positive philosophy! Thanks for the inspiring thought.
Thanks for reading. There are many articles on The DO Loop that do not involve matrix computations. In addition to serving SAS/IML programmers, I try to create content that appeals to Base SAS programmers, SAS/STAT analysts, and analysts who create statistical graphics.
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!
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.