Help using Base SAS procedures

vew all observation in proc univariate

Reply
Super Contributor
Posts: 395

vew all observation in proc univariate

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.

Super Contributor
Posts: 1,636

Re: vew all observation in proc univariate

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;

Super Contributor
Posts: 395

Re: vew all observation in proc univariate

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

Super User
Super User
Posts: 6,129

Re: vew all observation in proc univariate

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

Respected Advisor
Posts: 3,124

Re: vew all observation in proc univariate

Tom,

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

Haikuo

Ask a Question
Discussion stats
  • 4 replies
  • 92 views
  • 0 likes
  • 4 in conversation