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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

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

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 430 views
  • 1 like
  • 2 in conversation