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

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
  • 2 replies
  • 407 views
  • 1 like
  • 2 in conversation