Seems trival as long as the datasets are sorted by CODES.
data event21 ;
input Codes $ Event21 $;
cards;
A CDC
F JFK
G BOB
;
data event22 ;
input Codes $ Event22 $;
cards;
A EED
F UOP
G SNP-D
;
data event23 ;
input Codes $ Event23 $;
cards;
A EED
F UOP
G SNP-D
K BDP
;
data members ;
input MemberID DOB :mmddyy. Codes $;
format dob yymmdd10.;
cards;
123 1/30/2021 F
456 2/28/2022 G
789 3/30/2023 K
;
data want;
merge members(in=in1) event21-event23;
by codes ;
array events [2021:2023] event21-event23;
if in1;
if year(dob) in (2021:2023) then event = events[year(dob)];
drop event21-event23 ;
run;
Please explain the logic you would like to use.
Seems trival as long as the datasets are sorted by CODES.
data event21 ;
input Codes $ Event21 $;
cards;
A CDC
F JFK
G BOB
;
data event22 ;
input Codes $ Event22 $;
cards;
A EED
F UOP
G SNP-D
;
data event23 ;
input Codes $ Event23 $;
cards;
A EED
F UOP
G SNP-D
K BDP
;
data members ;
input MemberID DOB :mmddyy. Codes $;
format dob yymmdd10.;
cards;
123 1/30/2021 F
456 2/28/2022 G
789 3/30/2023 K
;
data want;
merge members(in=in1) event21-event23;
by codes ;
array events [2021:2023] event21-event23;
if in1;
if year(dob) in (2021:2023) then event = events[year(dob)];
drop event21-event23 ;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.