Help using Base SAS procedures

Proc Means output Dataset

Reply
N/A
Posts: 0

Proc Means output Dataset

Hi

I Want a dataset as it is the output produced by proc means.
ex:
data a;
input a b;
datalines;
1 2
3 4
5 6
;
proc means data=a;
run;
output:

variable n mean stddev minimum maximum
a 3 3.000000 2.000000 1.000000 2.000000
b 3 4.000000 2.000000 5.000000 6.000000



i want a dataset same above
N/A
Posts: 0

Re: Proc Means output Dataset

You can find everything you need here:

http://www.sfu.ca/sasdoc/sashtml/proc/z0146734.htm
N/A
Posts: 0

Re: Proc Means output Dataset

I want the data set in the form of

variable n mean stddev minimum maximum median
a 3 3.000000 2.000000 1.000000 2.000000 3.00000
b 3 4.000000 2.000000 5.000000 6.000000 4.00000
N/A
Posts: 0

Re: Proc Means output Dataset

I have a data set

data Houses;
input SQFEET BEDROOMS BATHS PRICE;
datalines;
1250 2 1.0 64000
1190 1 1.0 65850
1400 2 1.5 80050
1810 4 3.0 107250
1500 3 3.0 86650
1615 4 3.0 94450
1305 3 1.5 73650
1390 3 2.5 79350
1040 2 1.0 55850
2105 4 2.5 127150
1535 3 3.0 89100
1240 2 1.0 69250
720 1 1.0 34550
1745 4 2.5 102950
1860 2 2.0 110700
;

if i am using proc means :-
proc means data=houses ;
output out=mem (drop=_type_ _freq_);
run;


By default it will give N MEAN STD MIN MAX values
but i want MEDIAN also in this dataset.
N/A
Posts: 0

Re: Proc Means output Dataset

I would do this but there may be a better way:


proc means data=houses NOPRINT;
VAR SQFEET BEDROOMS BATHS PRICE;
output out=mem (drop=_type_ _freq_)N=SQFEET_N BEDROOMS_N BATHS_N PRICE_N
MEAN=SQFEET_MEAN BEDROOMS_MEAN BATHS_MEAN PRICE_MEAN
MAX=SQFEET_MAX BEDROOMS_MAX BATHS_MAX PRICE_MAX
MIN=SQFEET_MIN BEDROOMS_MIN BATHS_MIN PRICE_MIN
STD=SQFEET_STD BEDROOMS_STD BATHS_STD PRICE_STD
MEDIAN=SQFEET_MED BEDROOMS_MED BATHS_MED PRICE_MED;
run;
N/A
Posts: 0

Re: Proc Means output Dataset

A little bit of reading has shown me that the following will name the variables for you:


proc means data=houses NOPRINT;
output out=mem (drop=_type_ _freq_)N= MEAN= MAX= MIN= STD= MEDIAN=/autoname;
run;
Respected Advisor
Posts: 3,777

Re: Proc Means output Dataset

[pre]
data Houses;
input SQFEET BEDROOMS BATHS PRICE;
datalines;
1250 2 1.0 64000
1190 1 1.0 65850
1400 2 1.5 80050
1810 4 3.0 107250
1500 3 3.0 86650
1615 4 3.0 94450
1305 3 1.5 73650
1390 3 2.5 79350
1040 2 1.0 55850
2105 4 2.5 127150
1535 3 3.0 89100
1240 2 1.0 69250
720 1 1.0 34550
1745 4 2.5 102950
1860 2 2.0 110700
;;;;
run;

proc means noprint;
output out=stats;
output out=median median=;
run;
data stats;
set stats(in=in1) median(in=in2);
if in2 then _stat_ = 'MEDIAN';
run;
proc print;
run;
[/pre]
N/A
Posts: 0

Re: Proc Means output Dataset

Myra Olstik wrote a paper to present a macro to do this
A Better Means — The ODS Data Trap
http://www2.sas.com/proceedings/sugi31/059-31.pdf
(I got to help)

PeterC
Ask a Question
Discussion stats
  • 7 replies
  • 148 views
  • 0 likes
  • 2 in conversation