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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.