BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Onyx | Level 15

Hello
I want to calculate for each customer median  of variable X and then to re-merge it with the original data set.

Thank you so much

Data tbl1;
input ID ddate x;
cards;
1 1901 15
1 1902 18
1 1903 22
1 1904 16
1 1905 35
1 1906 18
1 1907 21
2 1901 10
2 1902 15
2 1903 13
2 1904 15
2 1905 30
2 1906 30
2 1907 28
3 1901 40
3 1902 40
3 1903 40
3 1904 40
3 1905 40
3 1906 40
3 1907 40
;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Do like this

 

proc sql;
    create table tbl2 as
    select *, median(x) as median_x
    from tbl1
    group by ID;
quit;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Do like this

 

proc sql;
    create table tbl2 as
    select *, median(x) as median_x
    from tbl1
    group by ID;
quit;
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 539 views
  • 1 like
  • 2 in conversation