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.
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?
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?
@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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.