BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

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.

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

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;

podarum
Quartz | Level 8

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

Tom
Super User Tom
Super User

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

Haikuo
Onyx | Level 15

Tom,

OP was asking for Median, but somehow median() is not support for group computation by proc SQL.

Haikuo

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 834 views
  • 0 likes
  • 4 in conversation