BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sathish_jammy
Lapis Lazuli | Level 10

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

This should work:

data BBB;

  merge AAA

        AAA(firstobs=2 keep=DATE rename=(DATE=FOLLOW_UP));

run;

 

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

This should work:

data BBB;

  merge AAA

        AAA(firstobs=2 keep=DATE rename=(DATE=FOLLOW_UP));

run;

 

Sathish_jammy
Lapis Lazuli | Level 10

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
;

 
 ID        date         FOLLOW_UP
1000309/26/200305/15/2004
1000305/15/200401/09/2007
1000301/09/200707/05/2007
1000307/05/200701/09/2007
1111101/09/200707/05/2007
1111107/05/2007.
On the 4th Obs followup should be null. Instead it get next value of different ID. Please let me know to solve it. Much Thanks!

 

ChrisNZ
Tourmaline | Level 20

In this case you need to also keep ID in the second table (rename it too) and compare the values

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
  • 3 replies
  • 845 views
  • 1 like
  • 2 in conversation