BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
7 REPLIES 7
deleted_user
Not applicable
You can find everything you need here:

http://www.sfu.ca/sasdoc/sashtml/proc/z0146734.htm
deleted_user
Not applicable
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
deleted_user
Not applicable
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.
deleted_user
Not applicable
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;
deleted_user
Not applicable
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;
data_null__
Jade | Level 19
[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]
deleted_user
Not applicable
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1064 views
  • 0 likes
  • 2 in conversation