BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

Hi everyone,

I have a pretty complex dataset  that looks like this:

ID      Date1        Event1        Date2      Event2    

1       4/5/13          a             7/4/13          r              

2       5/12/13        b             8/5/13          x                  

1       4/5/13          a            10/9/13         g           

3       7/7/12          a             5/5/13         m           

2      12/5/11          c            9/5/13          r             

Basically, each time a person experiences Event1 (corresponding to Date1), it generates a row. A person can experience multiple Event1s and thus generate multiple rows (eg ID 2 in the above example). The row also includes the date and type of event2 for that person. If a person has more than one Event2, it will generate another row for each Event1 (eg ID 1 in the example above).

What I want is to transpose this dataset so that it looks like this:

ID      Date1        Event1        DateR      DateX        DateG     DateM        

1       4/5/13          a             7/4/13          --            10/9/13       --                 

2       5/12/13        b             9/5/13        8/5/13          --             --                                 

3       7/7/12          a                --              --               --          5/5/13                 

2      12/5/11          c            9/5/13        8/5/13           --              --                       

The ultimate goal is to know how many people experienced events of each kind, and how long after the initial event. The problem is that if I transpose using the original Event2 variable as

the id variable, there are repeats and I'm not sure if/how that will work.

Any help is much appreciated!

1 REPLY 1
PGStats
Opal | Level 21

So, what do you want to happen with those repeats. Your expected data structure doesn't allow repeats. Do you want to keep only the first occurrence of a given type, or only the last, or something else?

PG

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 602 views
  • 0 likes
  • 2 in conversation