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

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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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