I need the median in a Proc Means output data set. It doesn't get output. But when I run the same step without output out= the median is in the listing. Any ideas? I haven't tried Proc Summary yet.
Here's the log and output I've produced. Comments explain what's going on.
** Generate 6 descriptive statistics including median/p50 and write values to an output data set. ;
380 proc means data=shared.&program(obs=500000)
381 n nmiss mean p50 std min max maxdec=0;
382 var amtFinanced;
383 output out=stats;
384 run;
NOTE: There were 500000 observations read from the data set SHARED.PRODV02_INDIRECT_TTD.
NOTE: The data set WORK.STATS has 5 observations and 4 variables.
** The note above says the output data set has 5 observations, not 6. The median is missing. ;
** In the source dataset the variable is formatted as dollar12. ;
** Here's the data set.
Obs _TYPE_ _FREQ_ _STAT_ AMTFINANCED
1 0 500000 N $500,000
2 0 500000 MIN $0
3 0 500000 MAX $34400368
4 0 500000 MEAN $18,756
5 0 500000 STD $54,091
** Now just print the 6 statistics, with no output data set. All is normal. ;
387 proc means data=shared.&program(obs=500000)
388 n nmiss mean p50 std min max maxdec=0;
389 var amtFinanced;
390 /* output out=stats;*/
391 run;
NOTE: There were 500000 observations read from the data set SHARED.PRODV02_INDIRECT_TTD.
** Here's the listing ;
The MEANS Procedure
Analysis Variable : AMTFINANCED $Financed
N N Miss Mean 50th Pctl Std Dev Minimum Maximum
------------------------------------------------------------------------------------------------
500000 0 18756 17359 54091 0 34400368
------------------------------------------------------------------------------------------------
The statistics in the PROC MEANS statement do not affect the data set in the OUTPUT statement. You could capture the ODS table or specifically specify the statistics in the OUTPUT statement. See the changes in your code below, specifically the highlighted portions. You should get two output data sets, see which one meets your needs.
proc means data=shared.&program(obs=500000) n nmiss mean p50 std min max maxdec=0 STACKODS;
var amtFinanced;
output out=stats1 n= nmiss= mean= p50= std= min=max=;
ods output summary = Stats2
run;
@bentleyj1 wrote:
I need the median in a Proc Means output data set. It doesn't get output. But when I run the same step without output out= the median is in the listing. Any ideas? I haven't tried Proc Summary yet.
Here's the log and output I've produced. Comments explain what's going on.
** Generate 6 descriptive statistics including median/p50 and write values to an output data set. ;
380 proc means data=shared.&program(obs=500000)
381 n nmiss mean p50 std min max maxdec=0;
382 var amtFinanced;
383 output out=stats;
384 run;
NOTE: There were 500000 observations read from the data set SHARED.PRODV02_INDIRECT_TTD.
NOTE: The data set WORK.STATS has 5 observations and 4 variables.
** The note above says the output data set has 5 observations, not 6. The median is missing. ;
** In the source dataset the variable is formatted as dollar12. ;
** Here's the data set.
Obs _TYPE_ _FREQ_ _STAT_ AMTFINANCED
1 0 500000 N $500,000
2 0 500000 MIN $0
3 0 500000 MAX $34400368
4 0 500000 MEAN $18,756
5 0 500000 STD $54,091
** Now just print the 6 statistics, with no output data set. All is normal. ;
387 proc means data=shared.&program(obs=500000)
388 n nmiss mean p50 std min max maxdec=0;
389 var amtFinanced;
390 /* output out=stats;*/
391 run;
NOTE: There were 500000 observations read from the data set SHARED.PRODV02_INDIRECT_TTD.
** Here's the listing ;
The MEANS Procedure
Analysis Variable : AMTFINANCED $Financed
N N Miss Mean 50th Pctl Std Dev Minimum Maximum
------------------------------------------------------------------------------------------------
500000 0 18756 17359 54091 0 34400368
------------------------------------------------------------------------------------------------
May I make a request? WHen you include parts of a SASLOG in your message, please click the {i} icon and paste your SASLOG into that window. THank you.
Your output statement has to include a request to compute medians.
output out=stats mean=mean_amtFinanced median=median_amtFinanced;
The statistics in the PROC MEANS statement do not affect the data set in the OUTPUT statement. You could capture the ODS table or specifically specify the statistics in the OUTPUT statement. See the changes in your code below, specifically the highlighted portions. You should get two output data sets, see which one meets your needs.
proc means data=shared.&program(obs=500000) n nmiss mean p50 std min max maxdec=0 STACKODS;
var amtFinanced;
output out=stats1 n= nmiss= mean= p50= std= min=max=;
ods output summary = Stats2
run;
@bentleyj1 wrote:
I need the median in a Proc Means output data set. It doesn't get output. But when I run the same step without output out= the median is in the listing. Any ideas? I haven't tried Proc Summary yet.
Here's the log and output I've produced. Comments explain what's going on.
** Generate 6 descriptive statistics including median/p50 and write values to an output data set. ;
380 proc means data=shared.&program(obs=500000)
381 n nmiss mean p50 std min max maxdec=0;
382 var amtFinanced;
383 output out=stats;
384 run;
NOTE: There were 500000 observations read from the data set SHARED.PRODV02_INDIRECT_TTD.
NOTE: The data set WORK.STATS has 5 observations and 4 variables.
** The note above says the output data set has 5 observations, not 6. The median is missing. ;
** In the source dataset the variable is formatted as dollar12. ;
** Here's the data set.
Obs _TYPE_ _FREQ_ _STAT_ AMTFINANCED
1 0 500000 N $500,000
2 0 500000 MIN $0
3 0 500000 MAX $34400368
4 0 500000 MEAN $18,756
5 0 500000 STD $54,091
** Now just print the 6 statistics, with no output data set. All is normal. ;
387 proc means data=shared.&program(obs=500000)
388 n nmiss mean p50 std min max maxdec=0;
389 var amtFinanced;
390 /* output out=stats;*/
391 run;
NOTE: There were 500000 observations read from the data set SHARED.PRODV02_INDIRECT_TTD.
** Here's the listing ;
The MEANS Procedure
Analysis Variable : AMTFINANCED $Financed
N N Miss Mean 50th Pctl Std Dev Minimum Maximum
------------------------------------------------------------------------------------------------
500000 0 18756 17359 54091 0 34400368
------------------------------------------------------------------------------------------------
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.