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
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!
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.