I need to create a new variable based on care interruption. RICF represents how many years from the event of interest. So ricf1=1 year since event, ricf2=2 years since event, ricf3=3 years since event, etc;
I want to create a variable that states how many years till the first interruption (YTI) which are circled in red. So for example
obs YTI
1 0
2 2
3 0
4 0
5 10
6 5
7 0
8 3
9 9
10 1
data want;
set have;
array t ricf1-ricf10;
_n_=whichn(0,of t(*))-1;
yti=ifn(sign(_n_)=-1,dim(t),_n_);
run;
data want;
set have;
array t ricf1-ricf10;
_n_=whichn(0,of t(*))-1;
yti=ifn(sign(_n_)=-1,dim(t),_n_);
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.