Hi all,
I am working on an oncology project to assess biochemical recurrence (BCR) defined as PSA >= 0.2. PSA values are collected up to 100 times with PSA dates for each value. I want to capture:
1) the first BCR value and the date it happens.
2) the first BCR value and the date it happens (ONLY if there are 2 consecutive BCR values).
I am trying to do this with an array and do loop. 2 variables - bcrvalue and bcrdate, will be created in the data step.
Thank you!
data have;
input ID $ psa1 psa2 psa3 psadate1 :mmddyy10. psadate2 :mmddyy10. psadate3 :mmddyy10.;
format psadate: mmddyy10.;
datalines;
1 0.1 0.1 1.5 3/05/2020 08/31/2020 08/05/2021
2 0.2 . . 3/05/2021 . .
3 3.3 0.1 . 3/05/2022 08/31/2022 .
4 0.2 0.5 5.5 3/05/2021 08/31/2021 08/05/2022
;
run;
1) the first BCR value and the date it happens.
2) the first BCR value and the date it happens (ONLY if there are 2 consecutive BCR values).
Is two different conditions. Since you don't show any with non-consecutive values then you need to show us what that would look like. And what the values of bcrvalue and bcrdate should be for an example with and without consecutive values.
I suspect there is something else going on that may not be clearly defined because from your example data the "first" values are always PSA1 and PSADATE1 so I am not sure where the complexity comes from. Or your representative data is not actually representative enough. Because there would be no actual use for an array as only psadate1 and psadate2 would ever be involved with satisfying the conditions.
Thank you for your response.
For the first condition/question, bcrvalue will be 1.5, bcrdate will be 08/05/2021 for Pt 1; bcrvalue will be 0.2, bcrdate will be 03/05/2021 for Pt 2; etc
For the second condition/question, bcrvalue and bcrdate will be missing for Pt 1, 2, & 3 since they don't have 2 consecutive BCR events. Pt 4 will be evaluated for this condition because they meet the criteria - bcrvalue will be 0.2, bcrdate will be 03/05/2021.
You say "Pt 1, 2, & 3 since they don't have 2 consecutive BCR events", but you still do not define what constitutes "consecutive".
I have to assume by PT you mean the values of ID in the example data. Please use the variable names or name your variables with the work you use in the discussion as that makes it much easier to follow.
I am especially confused about why PT 4, if it is indeed ID=4 qualifies when ID=1 does not. The dates are awfully similar for for ID 1 and 4 other than year. And neither seems "consecutive" to me.
I will accept that ID=2 is not "consecutive" as it only has one date/measurement. The values for the dates for ID=3, for the dates given are the same as ID=4 except for year and only having 2. So you really need to define "consecutive" as it is note a normal where "consecutive" dates would be one day apart. I might accept one month apart but your Id=4 doesn't meet that either.
data have; input ID $ psa1 psa2 psa3 psadate1 :mmddyy10. psadate2 :mmddyy10. psadate3 :mmddyy10.; format psadate: mmddyy10.; datalines; 1 0.1 0.1 1.5 3/05/2020 08/31/2020 08/05/2021 2 0.2 . . 3/05/2021 . . 3 3.3 0.1 . 3/05/2022 08/31/2022 . 4 0.2 0.5 5.5 3/05/2021 08/31/2021 08/05/2022 ; run;
Yes, I was referring to each ID as Pt (patient). I'll stay consistent with the use of ID.
I defined a BCR event as PSA greater than or equal to 0.2, so consecutive events are any back-to-back PSAs >= 0.2. So, you see the reason why ID 1 does not qualify. Please do not think too much about the dates being 1 day apart or 1 month apart - it's just an example.
How should the two different conditions be reflected in the desired result? Do you want a report or a dataset? What if there's missing values between BCR events?
STRONGLY consider transposing to a long dataset layout; this is usually easier to use in further processing.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.