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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 609 views
  • 0 likes
  • 4 in conversation