data have;
input ID Sex Injury_Type;
dataline
1 1 1
1 2
1 3
2 2 1
2 3
;
Data want;
input ID Sex Injury_Type;
dataline
1 1 1
1 1 2
1 1 3
2 2 1
2 2 3
;
Thanks
Su
Hello,
That's the LVCF-method (Last Value Carried Forward aka forward filling).
You find dozens of topic-threads on that subject within these communities.
Because your variables are all numeric, you can use PROC EXPAND (SAS/ETS).
data have;
input ID Sex Injury_Type;
datalines;
1 1 1
. 1 2
. 1 3
2 2 1
. 2 3
;
run;
PROC EXPAND data=have out=want(drop=time)
method=STEP EXTRAPOLATE;
convert _NUMERIC_;
run;
/* end of program */
[EDIT] Take care. This way (above) they are all (i.e. all 3 variables) filled. Maybe you just want
convert ID;
statement.
Koen
Hello,
That's the LVCF-method (Last Value Carried Forward aka forward filling).
You find dozens of topic-threads on that subject within these communities.
Because your variables are all numeric, you can use PROC EXPAND (SAS/ETS).
data have;
input ID Sex Injury_Type;
datalines;
1 1 1
. 1 2
. 1 3
2 2 1
. 2 3
;
run;
PROC EXPAND data=have out=want(drop=time)
method=STEP EXTRAPOLATE;
convert _NUMERIC_;
run;
/* end of program */
[EDIT] Take care. This way (above) they are all (i.e. all 3 variables) filled. Maybe you just want
convert ID;
statement.
Koen
Alternatively you may try
data have;
input ID Sex Injury_Type;
datalines;
1 1 1
. 1 2
. 1 3
2 2 1
. 2 3
;
run;
data want;
set have(rename=(id=_id));
by sex Injury_Type notsorted;
retain id;
if first.sex then id=.;
if _id ne . then id=_id;
run;
data have;
input ID Sex Injury_Type;
datalines;
1 1 1
. 1 2
. 1 3
2 2 1
. 2 3
;
run;
data want;
set have;
if ID then _iorc_ = ID;
else ID = _iorc_;
run;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.