What information in the two data sets tells us that the 130 is supposed to be replaced by the 3?
How many of these values do you have if this is just an example question? I am afraid that without some more to go on the ids in the second set are pretty much useless.
So the first, second, third, ... ID in the first dataset (let's call it HAVE1) is replaced by the first, second, third, ... ID in the second dataset (HAVE2), respectively?
If so, try this:
data want(drop=_);
retain id; /* redundant if order of variables is not important */
set have1(rename=(id=_));
if value='01' then set have2;
run;
data one;
input ID value:$2.;
cards;
123 01
123 02
123 03
130 01
131 01
131 02
133 01
136 01
136 02
136 03
;;;;
run;
data two;
input ID;
cards;
1
3
5
9
15
;;;;
run;
data key;
set one;
by id;
if first.id;
keep id;
run;
data fmt;
retain fmtname 'fmt' type 'i';
merge key(in=ina keep=id rename=(id=start)) two(rename=(id=label));
if ina;
run;
proc format cntlin=fmt;
run;
data want;
set one(rename=(id=_id));
id=input(_id,fmt.);
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!