Hi, I have searched the forum for help for my problem, and I think i have an idea how to solve it, but I need some more help. I would really appreciate if someone out there could help me. I am new to SAS EG and have limited SAS programming skills. I do however have a good understanding of general code.
My data set is structured as follows:
Occurrence ID (unique) Person ID Date Calculated column 1
x1 y1 n1
x2 y2 n2
x3 y1 n3
x4 y1 n4
I want to populate the calculated column according to how many days there are between two occurrences for a unique person.
For example:
For person ID = y1. Days between occurrence x3 and x1 = n3 - n1. The value will thereafter either set a 1, 2, 3 or 4 in the calculated column according to how many days there are.
My idea is to transpose the data set as follows:
Person ID (unique) x1 x2 x3 x4 Calculated column x1 Calculated column x2 ...
y1 n1 n2 n4
y2 n3
I can thereafter calculate by comparing columns x1,...xn for each person ID.
After this step, I need to transpose the data set back in order to have a unique calculated column values for each Occurrence ID.
Is this a good approach or do any of you have a better idea how I might attack this problem?
Thank you!
I don't know that you need to transpose but you will need to sort.

I don't know that you need to transpose but you will need to sort.

Thank you!
Much easier and exactly what I want to achieve.
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.