Hi, i'm sure this is such a simpel task, and I'm sure I've done before, amny years back. But for the life of me, I can't seem to remember how I can view all the observations after a proc univariate..
Ex.
A 5
A 6
A 7
B 10
B 12
B 14
after getting median in proc univarite I want to see
A 5 6
A 6 6
A 7 6
B 10 12
B 12 12
B 14 12
rather than
A 6
B 12
thank you.
you can merge the two datasets:
data one;
input var$ num;
cards;
A 5
A 6
A 7
B 10
B 12
B 14
;
data two;
input var $ m;
cards;
A 6
B 12
;
data three;
merge one two;
by var;
run;
proc print;run;
Yeah, that's what I ended up doing.. But for some reason I thought there was something in the procedure that I could add to do that... Thanks
You can do it with PROC SQL as it will automatically remerge the aggregate function results when you also select the detailed variables.
data have ;
input group $ val @@;
cards;
A 5 A 6 A 7 B 10 B 12 B 14
run;
proc sql noprint ;
create table want as
select group,val,mean(val) as mean_val
from have
group by group
;
quit;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.WANT created, with 6 rows and 3 columns.
A 5 6
A 7 6
A 6 6
B 14 12
B 12 12
B 10 12
Tom,
OP was asking for Median, but somehow median() is not support for group computation by proc SQL.
Haikuo
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.