BookmarkSubscribeRSS Feed
robaidi1
Calcite | Level 5

Hello,

 

I am still pretty basic with SAS programming but my supervisor assigned me an uneasy project that I have been stuck with for a while.

 

I have a primary dataset, each row constitute a spinal surgical hospitalization with variables like patient's age, gender, diagnoses..etc. A patient may have different rows (hospitalizations) in the same dataset. My project aim is to track readmissions in spinal surgical patients within 90 days of the procedure. I want to create a 0/1 variable for the first hospitalization of every spinal surgical patient with a value of 1 if the patient had ANY number of readmissions within 90 days.

 

To link patients there a 3 variables to be used:

 

Key: A unique number for every hospitalization ( every row has a unique key)

VisitLink: A value that is the same for the same patient across different hospitalizations

DaysToEvent: unique value that if you subtract it from the DaysToEvent value of different hospitalization it yields how many days there were between hospitalization.

 

I would really appreciate any help regarding how to create a final dataset with the first hospitalization for every patient and a variable that indicates if he got readmitted within 90 days or not.

3 REPLIES 3
ballardw
Super User

It really helps to provide a small example data set and then the desired result of that data set to clarify the variables and the logic. The example should include at least one case each for 1) no readmission for the topic 2) readmission for the topic within the time frame 3) readmission for the topic not within the time frame. The data only needs to provide examples, not sensitive data.

 

This statement is not exactly clear:

DaysToEvent: unique value that if you subtract it from the DaysToEvent value of different hospitalization it yields how many days there were between hospitalization.

As the text seems to imply that you subtract DaysToEvent from DaysToEvent. Which is why some example data is a very good idea.

I have a sneaking suspicion that without an actual date somewhere this may be awkward.

Data should be provided in the form of a data step. Which might look something like:

data example;
   input visitid $ visitlink $ days;
datalines;
1234  abc  1
1256  abc  6
1277  abc  23
1289  pdq  123
1299  pdq  145
;
run;

Since ids seldom should be involved in arithmetic I made the example values character variables.

 

robaidi1
Calcite | Level 5

I will try to give an example:

 

i would begin with 2 datasets, the first one (dataset1) is for all hospitalization in a hospital and the second dataset (dataset2) is only for my target population which are spinal surgical patients.

 

dataset1 example;
input KEY $ visitlink $ daystoevent age gender $;
datalines;
100001 1551 15291 57 m
100002 1442 26291 60 f

100003 1551 15297 57 m
100004 1667 15291 57 m
100005 1442 26383 60 f
100006 1234 35233 71 m
100007 1980 44551 83 m
;
run;

 

dataset2 example;
input KEY $ visitlink $ daystoevent age gender $;
datalines;
100001 1551 15291 57 m
100002 1442 26291 60 f
100007 1980 44551 83 m
;
run;

 

 

My results final dataset would look like this: (dataset3)

 

dataset3 example;
input KEY $ visitlink $ daystoevent age gender $ readmission $ daystoreadmission;
datalines;
100001  1551  15291  57  m  1  6
100002  1442  26291  60  f    0  92
100007  1980  44551  83  m   0  0
;
run;

 

If you notice the way I calculated daystoreadmission in the final dataset is by subtracting daystoevent in dataset1 from daystoevent in dataset2, if the number was 1-90 I would give the patient a "1" value in the readmission variable, if it was more than 90 days I would give a 0 value like in the second patient in dataset3. If a patient had multiple readmissions I would only use the first readmission occurring following surgery.

 

Please let me know if I can provide more information. Thank you. 

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
  • 1076 views
  • 0 likes
  • 2 in conversation