BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

 

Hi Commuinity,

 

I have a Vital Signs dataset below which I want to add a column to flag the differences of Systolic Blood Pressure from Baseline to 2 hours, 2 hours to 24 hours. 24 hours to 48 hours and 48 hours to Day 5 for every single patient in the dataset.

Any ideas?

Thank you

PatientVisitSystolic Blood PressureDiastolic Blood Pressure
1001Baseline14682
1001hr211959
1001hr2413371
1001hr4810251
1001D512877
1002Baseline12276
1002hr215078
1002hr2411561
1002hr4812173
1002D514285
1003Baseline10259
1003hr211077
1003hr2411158
1003hr4812478
1003D510868
1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

You want a sequence of differences between   systolicbp{I}-systolicbp{i-1}, where i is the observations number. And for the first obs of each patient, you want the difference reset to missing.

 

Use the DIF function, which is defined as    DIF(x)=x-lag(X).

 

data want;
  set have;
  by patient;
  systolic_diff=dif(systolicbp);
  if first.patient then systolic_diff=.;
run;

 

Edited addition: I should have added that this program assumes there are no "holes" in the data.  I.e. each patient has a record for every time point, in sequence.

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

--------------------------

View solution in original post

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

proc transform would be the tool I would use.

 

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_prinqual_se...

 

https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

 

then evaluate the your client across your time progression of  base, 2, 24, 48 and day5 by arraying the time intervals

 

mkeintz
PROC Star

You want a sequence of differences between   systolicbp{I}-systolicbp{i-1}, where i is the observations number. And for the first obs of each patient, you want the difference reset to missing.

 

Use the DIF function, which is defined as    DIF(x)=x-lag(X).

 

data want;
  set have;
  by patient;
  systolic_diff=dif(systolicbp);
  if first.patient then systolic_diff=.;
run;

 

Edited addition: I should have added that this program assumes there are no "holes" in the data.  I.e. each patient has a record for every time point, in sequence.

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

--------------------------

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