BookmarkSubscribeRSS Feed
mbrlvlctrl
Calcite | Level 5

Hello Community,

I just need help getting ideas on how to approach this and it seems simple, but I can only think of inefficient ways to get this done.

I have information dealing with start and end dates but it is currently set up so that if a person comes in multiple times, it's a separate observation in itself

id   start            end

1    1/1/10          1/10/10

1    2/25/10         3/1/10

kind of like that.

I want to make it so it looks like this

id   start1          end1        start2          end2

1    1/1/10         1/10/10     2/25/10       3/1/10

Any guidance would be helpful.

1 REPLY 1
Astounding
PROC Star

Does efficiency really matter?  You only need to transform the data once.  Anyway here's one way (assuming your data is sorted by ID):

proc transpose data=have prefix=start out=start_dates;

   by id;

   var start;

run;

proc transpose data=have prefix=end out=end_dates;

   by id;

   var end;

run;

data want;

   merge start_dates end_dates;

   by id;

run;

You will find that some programming tasks are easier, but they now depend on you knowing how many start and end dates you have.

Good luck.

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
  • 1 reply
  • 659 views
  • 1 like
  • 2 in conversation