I am working with the following dataset
data have;
input repricingdate1-repricingdate3;
datalines;
'30SEP2019'd '31DEC2020'd '31MAR2022'd
'31DEC2020'd '30JUN2023'd '31DEC2025'd
;
run;
please excuse me if that's not the correct way to input dates, I'm unsure but I have a table with those values using an intnx function
I am looking to create a variable "Flag" which returns a '1' if the repricingdate matches the Flag year i.e. Flag(2019)=1 for the first line, Flag(2020)=1 for both lines and so on.
I am using the below code and can't see where my mistake lies, it even picks up a couple of rows in a larger dataset but is sporadic
data want;
set have;
array flag(2018:2021) flag2018-flag2021;
array repricingdate(1:3);
do i = 2018 to 2021;
do j = 1 to 3;
if put(repricingdate(j), 4.) = compress(vname(flag(i)),, 'kd')
then flag(i)=1;
end;
end;
drop i;
run;
I would appreciate it if someone could point out my mistake, thank you.