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

Greetings!

I have a Vital Sign dataset - systolic and diastolic blood pressure measured pre and post dose

SiteSubjectVisitDate of AssessmentVS TestResult
11001Baseline2019-12-06T20:01:00Systolic_BP111
11001Baseline2019-12-06T20:01:00Diastolic_BP75
11001Baseline2019-12-06T20:01:00Pulse89
11001predose2019-12-06T21:32:00Systolic_BP157
11001predose2019-12-06T21:32:00Diastolic_BP72
11001postdose2019-12-06T21:43:00Systolic_BP112
11001postdose2019-12-06T21:43:01Diastolic_BP64

 

I want to check the consecutive Systolic and Diastolic results be compared and if there is a drop of > 40 between predose and post dose, then flagged it as below

 

SiteSubjectVisitDate of AssessmentVS TestResultFlag
11001Baseline2019-12-06T20:01:00Systolic_BP111 
11001Baseline2019-12-06T20:01:00Diastolic_BP75 
11001Baseline2019-12-06T20:01:00Pulse89 
11001predose2019-12-06T21:32:00Systolic_BP157 
11001predose2019-12-06T21:32:00Diastolic_BP72 
11001postdose2019-12-06T21:43:00Systolic_BP112Drop of > 40mmHg
11001postdose2019-12-06T21:43:01Diastolic_BP64 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

To be clear you want to compare Predose Systolic with Postdose Systolic and Predose Diastolic with Postdose Diastolic for the same subject?

Do you ever have more than one predose measure other than perhaps that baseline?

 

I would suggest having 2 different flag variables so you don't get confused, one each for systolic and diastolic.

My start would look something like the following untested code.

data want;
   set have;
   by site subject;
   retain presys predia;
   if first.subject then call missing(presys, predia);
   If visit='predose' and vs_test = "Systolic_BP" then presys=result;
   If visit='postdose' and vs_test = "Systolic_BP" then FlagSys = ((presys - result)>40 );
   If visit='predose' and vs_test = "Diastolic_BP" then presys=result;
   If visit='postdose' and vs_test = "Diastolic_BP" then FlagDia = ((predia - result)>40 );
   label
      FlagSys = "Systolic Flag drop > 40"
      FlagDia = "Systolic Flag drop > 40"
   ;
   drop presys predia;
run;

The flags are numeric 1 when true and 0 for false. There are some good reasons to include both, and are set only on the post dose visit for each measure. You could make custom format if you really need to see text like "drop > 40".

Reasons to have two variables: If you use proc report or tabulate to create summaries of the data you can use the N statistic with each to get how many comparisons were performed (I would expect this to be subjects but may be wrong), the Sum statistic would tell you how many had the drop and Mean statistic would give you the percentage of drops in a somewhat cleaner manner than would be needed with character values for two different results in the same variable.

 

I am assuming your data is in an appropriate order, sorted by site, subject and that "date of assessment". If that is not the case then a sort should be done prior.

View solution in original post

2 REPLIES 2
ballardw
Super User

To be clear you want to compare Predose Systolic with Postdose Systolic and Predose Diastolic with Postdose Diastolic for the same subject?

Do you ever have more than one predose measure other than perhaps that baseline?

 

I would suggest having 2 different flag variables so you don't get confused, one each for systolic and diastolic.

My start would look something like the following untested code.

data want;
   set have;
   by site subject;
   retain presys predia;
   if first.subject then call missing(presys, predia);
   If visit='predose' and vs_test = "Systolic_BP" then presys=result;
   If visit='postdose' and vs_test = "Systolic_BP" then FlagSys = ((presys - result)>40 );
   If visit='predose' and vs_test = "Diastolic_BP" then presys=result;
   If visit='postdose' and vs_test = "Diastolic_BP" then FlagDia = ((predia - result)>40 );
   label
      FlagSys = "Systolic Flag drop > 40"
      FlagDia = "Systolic Flag drop > 40"
   ;
   drop presys predia;
run;

The flags are numeric 1 when true and 0 for false. There are some good reasons to include both, and are set only on the post dose visit for each measure. You could make custom format if you really need to see text like "drop > 40".

Reasons to have two variables: If you use proc report or tabulate to create summaries of the data you can use the N statistic with each to get how many comparisons were performed (I would expect this to be subjects but may be wrong), the Sum statistic would tell you how many had the drop and Mean statistic would give you the percentage of drops in a somewhat cleaner manner than would be needed with character values for two different results in the same variable.

 

I am assuming your data is in an appropriate order, sorted by site, subject and that "date of assessment". If that is not the case then a sort should be done prior.

zimcom
Pyrite | Level 9
Thank you !!!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 558 views
  • 1 like
  • 2 in conversation