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!
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.