BookmarkSubscribeRSS Feed
TheBlackBishop1
Fluorite | Level 6

Hi, I am having trouble figuring out how to program a set of conditions. Below is the code and conditions and where i need help. I have attached a sas dataset 'test' with 5 variables - Time1, Time2, Creat_cat, PT_cat and PF_ratio. I am trying to create a new variable 'Severity' with the following conditions. Thank you in advance.

 

Data test;
if Creat_cat ='Greater than 1.8' and PT_cat = '<300'
/* (for MORE THAN 48 hours at anytime between Time1 and Time2)- I need help here*/
then Severity = 'severe';
if Creat_cat ='Greater than 1.8' and PT_cat = '<300'
/* (for LESS THAN 48 hours at anytime between Time1 and Time2)- I need help here*/
then Severity = 'Moderate';
else Severity = 'Mild';
run;

 

TheBlackBishop1_1-1650836057863.png

 

 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

for MORE THAN 48 hours at anytime between Time1 and Time2

 

I don't understand what this means. Do you mean that Time1 and Time2 are more than 48 hours apart? Or do you mean something else? If you mean something else, please give us concrete examples (plural) of what you mean.

--
Paige Miller
TheBlackBishop1
Fluorite | Level 6

Thank you for your help. I have updated the dataset for clarity.

Each record is for a specific timestamp , RECORDED_DATE
ID is the record number (unique to each patient)
enc is the hospital encounter number for a particular visit
Time1 is the admission time
Time2 is the discharge time
Creat_cat is creatinine as a dichotomous variable (<1.8 and >1.8)
PT_cat is a dichotomous variable (<300 and >=300)
If a patient (ID) has Creat_cat >1.8 or PT_cat <300 for more than 48hours at anytime between Time1 and Time2 (during admission), I would like to classify them as 'severe'.

If a patient (ID) has Creat_cat >1.8 or PT_cat <300 for less than 48hours at anytime between Time1 and Time2(during admission), I would like to classify them as 'moderate'.

If a patient (ID) does not satisfy either condition (of time), I would like to classify them as mild.

PaigeMiller
Diamond | Level 26

How is this calculation of "for more than 48 hours" done? Please give concrete examples. Please don't make me have to repeatedly ask for information.

--
Paige Miller
TheBlackBishop1
Fluorite | Level 6
I am sorry i am not clear enough. That is what i am trying to calculate so I don't have any examples. From my understanding, it is any 48 hour window between time 1 and time 2. If the condition the condition satisfies that then it is severe. Thanks
PaigeMiller
Diamond | Level 26

I don't know what this means relative to the data provided. I have asked for the meaning of this 48 hour interval, and how it is calculated from the data, and you haven't answered. If you can't show us a concrete example (even if it is made up), then I don't see how to proceed.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 5 replies
  • 636 views
  • 0 likes
  • 2 in conversation