Greetings!
I have a Vital Sign dataset - systolic and diastolic blood pressure measured pre and post dose
Site | Subject | Visit | Date of Assessment | VS Test | Result |
1 | 1001 | Baseline | 2019-12-06T20:01:00 | Systolic_BP | 111 |
1 | 1001 | Baseline | 2019-12-06T20:01:00 | Diastolic_BP | 75 |
1 | 1001 | Baseline | 2019-12-06T20:01:00 | Pulse | 89 |
1 | 1001 | predose | 2019-12-06T21:32:00 | Systolic_BP | 157 |
1 | 1001 | predose | 2019-12-06T21:32:00 | Diastolic_BP | 72 |
1 | 1001 | postdose | 2019-12-06T21:43:00 | Systolic_BP | 112 |
1 | 1001 | postdose | 2019-12-06T21:43:01 | Diastolic_BP | 64 |
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
Site | Subject | Visit | Date of Assessment | VS Test | Result | Flag |
1 | 1001 | Baseline | 2019-12-06T20:01:00 | Systolic_BP | 111 | |
1 | 1001 | Baseline | 2019-12-06T20:01:00 | Diastolic_BP | 75 | |
1 | 1001 | Baseline | 2019-12-06T20:01:00 | Pulse | 89 | |
1 | 1001 | predose | 2019-12-06T21:32:00 | Systolic_BP | 157 | |
1 | 1001 | predose | 2019-12-06T21:32:00 | Diastolic_BP | 72 | |
1 | 1001 | postdose | 2019-12-06T21:43:00 | Systolic_BP | 112 | Drop of > 40mmHg |
1 | 1001 | postdose | 2019-12-06T21:43:01 | Diastolic_BP | 64 |
Thank you!
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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.