BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Srigyan
Quartz | Level 8

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:

 

 

VariableN MissNMeanMedianModeMinimumMaximum
identifier0509693255001.16255004.1510000
birth_year475096461978.571981199019001999
date_start050969320287.4520283207831972420819
date_default4778863180720527.2820565206331987120893
date_completed22148728820620429.4620423206751972520895
date_last_payment16233634735720509.9920588208781972420896
open_to_buy_amt0509693233.99252300-1141010000
LTIME_NET_SALES_AMT0509693343.15919747.990-202428336.7
LTIME_NO_ORDERS05096933.4911663110483
LTIME_RETURNED_AMT050969359.325123400016231.2

 

but the table has different result.

 

How can I get the same result in dataset what we see in the result.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@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.

 

 

View solution in original post

11 REPLIES 11
PaigeMiller
Diamond | Level 26
output out=abc nmiss=nmiss n=n mean=mean median=median mode=mode
    min=minimum max=maximum;
--
Paige Miller
Srigyan
Quartz | Level 8

This is giving me overall count instead of variable wise.

Srigyan
Quartz | Level 8
_TYPE__FREQ_nmissnmeanmedianmodeminimummaximum
05096930509693255001255004.1510000
ballardw
Super User

@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.

 

Reeza
Super User

@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.

 

 

Srigyan
Quartz | Level 8

what is stackods?

Reeza
Super User

@Srigyan wrote:

what is stackods?


Example 13: Using the STACKODSOUTPUT Option to Control Data

https://documentation.sas.com/?docsetId=proc&docsetTarget=p17h6q7ygvkl1sn13qzf947dundi.htm&docsetVer...

 

 

 

https://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n1qnc9bddfvhzqn105kqitnf...

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.

PaigeMiller
Diamond | Level 26

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;
--
Paige Miller
Ksharp
Super User

Another way is PROC UNIVARIATE.

Pick stat you need.

 

proc univariate data=sashelp.class outtable=want noprint;
var _numeric_;
run;

proc print;run;
Srigyan
Quartz | Level 8

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

 

Ksharp
Super User

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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 1243 views
  • 1 like
  • 5 in conversation