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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.