BookmarkSubscribeRSS Feed
eclaire
Calcite | Level 5

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'.

3 REPLIES 3
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
eclaire
Calcite | Level 5

I just edited my post to include this, thanks!

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
  • 3 replies
  • 814 views
  • 1 like
  • 3 in conversation