Dear Experts,
I want to update the missing Height value in my table for the given IDs
Kindly go through my sample set for detail.
data have;
input ID date mmddyy10. Heigth weight;
format date mmddyy10.;
cards;
101 12/06/1993 159 67
101 10/08/1994 . 61
101 06/01/2000 . .
102 08/08/2001 . 87
102 07/30/2002 160 .
102 11/03/2004 . 65
;
Expected Result:
ID | date | Heigth | weight |
101 | 12/06/1993 | 159 | 67 |
101 | 10/08/1994 | 159 | 61 |
101 | 06/01/2000 | 159 | . |
102 | 08/08/2001 | 160 | 87 |
102 | 07/30/2002 | 160 | . |
102 | 11/03/2004 | 160 | 65 |
Please suggest some ideas to solve the given program.
Much Thanks!
data have;
input ID date mmddyy10. Heigth weight;
format date mmddyy10.;
cards;
101 12/06/1993 159 67
101 10/08/1994 . 61
101 06/01/2000 . .
102 08/08/2001 . 87
102 07/30/2002 160 .
102 11/03/2004 . 65
;
run;
data have_1;
set have (where=(Heigth ne .));
keep id Heigth;
run;
proc sort data=have;by id;run;
proc sort data=have_1;by id;run;
data want;
merge have(in=aa drop=Heigth) have_1(in=aa);
by id;
if aa=1;
run;
data have;
input ID date mmddyy10. Heigth weight;
format date mmddyy10.;
cards;
101 12/06/1993 159 67
101 10/08/1994 . 61
101 06/01/2000 . .
102 08/08/2001 . 87
102 07/30/2002 160 .
102 11/03/2004 . 65
;
run;
data have_1;
set have (where=(Heigth ne .));
keep id Heigth;
run;
proc sort data=have;by id;run;
proc sort data=have_1;by id;run;
data want;
merge have(in=aa drop=Heigth) have_1(in=aa);
by id;
if aa=1;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.