BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ifti_ch2002
Obsidian | Level 7
data have;
infile datalines missover; 
   input IDnumber @3 date  mmddyy10.;
   datalines;  
1 4-7-2003 
1 4-7-2009 
1 4-7-2010 
1 4-7-2011 
1 4-7-2012 
1 4-7-2013 
1 4-7-2014 
1 4-7-2015 
1 4-7-2016 
1 4-7-2018 
2 4-7-2005 
2 4-7-2011 
2 4-7-2012 
2 4-7-2013 
2 4-7-2014 
2 4-7-2015 
2 4-7-2016 
2 4-7-2017 
2 4-7-2018 
2 4-7-2019 
2 4-7-2020 
;       
run; 
data want;
infile datalines missover; 
   input IDnumber @3 date  mmddyy10. @12 index_date  mmddyy10.;
   datalines;  
1 4-7-2003  4-7-2003
1 4-7-2009  4-7-2009
1 4-7-2010  4-7-2009
1 4-7-2011  4-7-2009
1 4-7-2012 4-7-2009
1 4-7-2013 4-7-2009
1 4-7-2014 4-7-2014
1 4-7-2015 4-7-2014
1 4-7-2016 4-7-2014
1 4-7-2018 4-7-2014
2 4-7-2005 4-7-2005
2 4-7-2011 4-7-2011
2 4-7-2012 4-7-2011
2 4-7-2013 4-7-2011
2 4-7-2014 4-7-2011
2 4-7-2015 4-7-2011
2 4-7-2016 4-7-2016
2 4-7-2017  4-7-2016
2 4-7-2018  4-7-2016
2 4-7-2019  4-7-2016
2 4-7-2020  4-7-2016
;       
run; 

Hi,

I have data with the different dates by grouping variable "IDnumber". I have calculated index date based on the condition, if first "idnumber" or the difference between current date and lag(date) is greater than 4 years. What i need is to repeat the index date until new index date within the same group. For example the index date on the second line will be repeated untill line number seven.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I have calculated index date based on the condition, if first "idnumber" or the difference between current date and lag(date) is greater than 4 years

 

I don't see how the part in red is applied to obtain the desired result.
Why does index date change at 4-7-2014?

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I have calculated index date based on the condition, if first "idnumber" or the difference between current date and lag(date) is greater than 4 years

 

I don't see how the part in red is applied to obtain the desired result.
Why does index date change at 4-7-2014?

--
Paige Miller
ifti_ch2002
Obsidian | Level 7

@PaigeMiller, i accidently accepted the solution. Current date i mean if on the row second then the current date is on the second row. But this is not the question. Question is only to repeat the index date until new index date. Updated question is on the following

https://communities.sas.com/t5/SAS-Programming/Repeat-Index-Date/m-p/647182#M193653

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 747 views
  • 0 likes
  • 2 in conversation