Hello, I am working with a data set that includes multiple therapy days for patients and I am trying to group the therapy activities into two groups: admission and discharge based on whether they are a week within the admit or discharge dates for each person. I am having trouble figuring out the best way to do this since I am unsure how to do it for each person. The data is from Redcap and the therapy activities were done using a repeat variable so each therapy session is a separate row in the dataset and there are approximately 10-20 of these rows for each patient. I hope this makes sense. I have tried to use an if/then statement but it doesn't recognize that there are multiple patients and consolidates them all as a whole. I'm kind of new with SAS but I am happy to clarify any questions if this doesn't make sense. Thank you!
Sample data:
data covid;
input recordid addate ddate actdate acttype;
datalines;
1 1/2/2020 3/3/2020 . .
1 . . 3/1/2020 1
1 . . 1/3/2020 3
2 1/3/2020 3/4/2020 . .
2 . . 1/4/2020 4
2 . . 3/3/2020 5
run;
So for each recordid there are many rows beneath it for different therapy activities for that person. I need to categorize each therapy session (actdate) as 'admission' or 'discharge' based on whether they are a week within the addate (admission date) or a week within the ddate (discharge data). And this needs to be done for each recordid. So for the first one (recordid 1), the 1/3/2020 is a week within the addate (1/2/2020) and so needs to be categorized as 'admission'.
Please provide sample data in the form of a working data step. Then we can provide well-formed suggestions and can test any suggested program.
And please show also what you want the result to look like, to assess any test program.
Help us help you.
I just edited my post to include this, thanks!
You missed an important word in @mkeintz 's post: working.
Your data step does not create a useful dataset, please correct it.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.