When I run the following code.
proc means data=sd.customer NMISS N mean median mode min max ; output out=abc; run;
I get the following result:
Variable | N Miss | N | Mean | Median | Mode | Minimum | Maximum |
identifier | 0 | 509693 | 255001.16 | 255004 | . | 1 | 510000 |
birth_year | 47 | 509646 | 1978.57 | 1981 | 1990 | 1900 | 1999 |
date_start | 0 | 509693 | 20287.45 | 20283 | 20783 | 19724 | 20819 |
date_default | 477886 | 31807 | 20527.28 | 20565 | 20633 | 19871 | 20893 |
date_completed | 221487 | 288206 | 20429.46 | 20423 | 20675 | 19725 | 20895 |
date_last_payment | 162336 | 347357 | 20509.99 | 20588 | 20878 | 19724 | 20896 |
open_to_buy_amt | 0 | 509693 | 233.992523 | 0 | 0 | -11410 | 10000 |
LTIME_NET_SALES_AMT | 0 | 509693 | 343.159197 | 47.99 | 0 | -2024 | 28336.7 |
LTIME_NO_ORDERS | 0 | 509693 | 3.4911663 | 1 | 1 | 0 | 483 |
LTIME_RETURNED_AMT | 0 | 509693 | 59.3251234 | 0 | 0 | 0 | 16231.2 |
but the table has different result.
How can I get the same result in dataset what we see in the result.
@Srigyan wrote:
This is giving me overall count instead of variable wise.
proc means data=sd.customer NMISS N mean median mode min max STACKODS;
ods output summary=abc;
run;
The statistics on the OUTPUT statement control what goes to the OUT=data set.
The statistics on the PROC MEANS statement control what goes to the ODS output (listing/HTML). If you want the ODS table, you need an ODS statement and I like the STACKODS option to get it in a clean format.
output out=abc nmiss=nmiss n=n mean=mean median=median mode=mode
min=minimum max=maximum;
This is giving me overall count instead of variable wise.
_TYPE_ | _FREQ_ | nmiss | n | mean | median | mode | minimum | maximum |
0 | 509693 | 0 | 509693 | 255001 | 255004 | . | 1 | 510000 |
@Srigyan wrote:
_TYPE_ _FREQ_ nmiss n mean median mode minimum maximum 0 509693 0 509693 255001 255004 . 1 510000
Without posting the EXACT code that you ran, preferably from the log with any notes, it is hard to tell what you may have done
Add / autoname to the OUTPUT statement after the requested statistics on the OUTPUT statement. The statistics on the proc statement do not affect the content of the output data set.
That will add variables with _mean _min _max etc. appended to the variable names.
@Srigyan wrote:
This is giving me overall count instead of variable wise.
proc means data=sd.customer NMISS N mean median mode min max STACKODS;
ods output summary=abc;
run;
The statistics on the OUTPUT statement control what goes to the OUT=data set.
The statistics on the PROC MEANS statement control what goes to the ODS output (listing/HTML). If you want the ODS table, you need an ODS statement and I like the STACKODS option to get it in a clean format.
what is stackods?
@Srigyan wrote:
what is stackods?
STACKODSOUTPUT
produces an ODS output object whose data set resembles the printed output.
The STACKODSOUTPUT option affects output data sets created by ODS OUTPUT statements, not the PROC MEANS OUTPUT statement.
Alias STACKODS See Using the STACKODSOUTPUT Option to Control Data
Please refer to the SAS documentation, it is quite detailed and helpful.
You need to specify the variables by using the VAR statement.
proc means data=whatever nmiss n mean median mode min max;
var identifier birth_year ... ; /* You type the rest */
output out=abc nmiss=nmiss n=n mean=mean median=median mode=mode
min=minimum max=maximum;
run;
Another way is PROC UNIVARIATE.
Pick stat you need.
proc univariate data=sashelp.class outtable=want noprint;
var _numeric_;
run;
proc print;run;
how to get all these details for char & numeric both. I can understand all thing are not possible for char but atleast n,nmiss and unique value in each column. How can i get it in a sas dataset.
if you have something for this...I didn't find any answer yet.
https://communities.sas.com/t5/SAS-Programming/Exploratory-analysis-macro/m-p/562031#M157402
Try SQL.
proc sql;
select sex,n(name) as n,nmiss(name) as nmiss,
count(distinct name) as distinct_name
from sashelp.class
group by sex;
quit;
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.