Hi experts,
I need a clarification in the following sample data set. I need to update the followup dates in separate column.
data aaa;
input ID date mmddyy10.;
format date mmddyy10.;
cards;
10003 09/26/2003
10003 05/15/2004
10003 01/09/2007
10003 07/05/2007
;
Expected Output
+---------+-----------------+---------------+
| id | date | follow_up |
+---------+-----------------+---------------+
| 10003 | 2003-09-26 | 2004-05-15 |
| 10003 | 2004-05-15 | 2007-01-09 |
| 10003 | 2007-01-09 | 2007-07-05 |
| 10003 | 2007-07-05 | . |
+---------+----------------+----------------+
Please suggest some idea to organize the followup date as given above.
Thanks in advance!
This should work:
data BBB;
merge AAA
AAA(firstobs=2 keep=DATE rename=(DATE=FOLLOW_UP));
run;
This should work:
data BBB;
merge AAA
AAA(firstobs=2 keep=DATE rename=(DATE=FOLLOW_UP));
run;
Dear @ChrisNZ
Thank u so much for your response. It works well.
but I have a question in this datastep.
For exmpl :
data aaa;
input ID date mmddyy10.;
format date mmddyy10.;
cards;
10003 09/26/2003
10003 05/15/2004
10003 01/09/2007
10003 07/05/2007
11111 01/09/2007
11111 07/05/2007
;
10003 | 09/26/2003 | 05/15/2004 |
10003 | 05/15/2004 | 01/09/2007 |
10003 | 01/09/2007 | 07/05/2007 |
10003 | 07/05/2007 | 01/09/2007 |
11111 | 01/09/2007 | 07/05/2007 |
11111 | 07/05/2007 | . |
In this case you need to also keep ID in the second table (rename it too) and compare the values
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.