BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jadenmcbroom
Calcite | Level 5

jadenmcbroom_0-1609613631150.png

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 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data want;
 set have;
 array t ricf1-ricf10;
 _n_=whichn(0,of t(*))-1;
 yti=ifn(sign(_n_)=-1,dim(t),_n_);
run;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20
data want;
 set have;
 array t ricf1-ricf10;
 _n_=whichn(0,of t(*))-1;
 yti=ifn(sign(_n_)=-1,dim(t),_n_);
run;

sas-innovate-white.png

Register Today!

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.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 466 views
  • 0 likes
  • 2 in conversation