Hey everyone,
I have to do some analysis on a pharmaceutical dataset.
By selecting the right interval I lack the right idea for continuing.
I would be grateful if someone could help me 🙂
My data:
I am working with a dataset which contains measurements (like temperature, weight etc.) from patients over different timepoints.
Patient Day Parameter Value
1 1 Temperature 37
2 38.5
3 39
4 -
5 -
6 35.9
7 38
8 -
9 -
10 38.5
11 -
12 39.3
13 -
14 38
15 -
16 36.9
17 -
2 1 -
... ...
23 37.6
My task:
For my analysis I want to determine a 14-days interval in which at least 7 values are not missing.
I am starting with the measurement on the last day (so first I sort the dataset in descending sequence). therefore for patient 1 with the intervall [Day 17 to Day 4]. In this example the interval doesn't contain 7 non-missing values.
So I have to move the interval from [Day 17 to 4] to [Day 16 to 3] and have to check the number of non-missing values
again. Now there are 7 non-missing values in the interval, I can give out the start and end day of the interval and use it for analysis.
So all in all, I start with the interval [last Day - (last Day - 14)] and move it forward until I reach an interval which contains at
least 7 non-missing values. This interval should be determined for each patient and each parameter.
My solution:
First I sort the dataset in descending sequence. After that I have transpose the dataset twice - for the variable Day and Value. Then I have created two arrays - _days and _values.
Now I count the missing values in the interval from position 1 to 14. If the value is greater than 7, then I have to move the interval. I have tried to realize it with a do-while loop.
Does everyone has an idea how to solve that problem?
Thanks for your help!
Kind regards,
Saskia
What do you want the output to look like?
I think that you want a zero-based array of length 14, something like this:
data want;
array measures(0:13) 8 _temporary_;
call missing(of measures(*));
do _N_=1 by 1 until(last.patient);
set have;
by patient;
measures(mod(_N_,14))=parameter;
if _N_>=14 and n(of measures(*))>=7 then
output;
end;
run;
That way, the array will just keep cycling, and will always contain the latest 14 values.
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!
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.