@Romain69100 wrote:
Thank you for your quick reply :).
I am at home for the moment (France) so i will test it tomorrow.
For individuals with non missing missing values and and status=0 does the code will increment for time_to_status the last day of follow up?
It does this: "I want to create a new variable time_to_status which will take the following values: 4 , 3, 5,1 for individus 1,2,3,4 respectively."
If I am understanding properly, then no array needed. You don't specifically state if you have 20 status variables, such as status1 status2 etc. but assuming you do have this
time_to_event = whichn(1,of status1-status20);
Okay so your description to me is contradictory and not making sense. You said earlier "I have a binary indicator (status)which is equal to 1 if tiredness is greater or equal to 80 and 0 otherwise." Wouldn't there be 20 of these? But now you say the first occurrence of 80 is in day 4 but don't mention the status variable at all.
The best thing to do is to show us a small portion of the data, following these instructions, or type in SAS data step code by yourself — and not via any other method. You can, if you want, assume there are only 5 time periods, we just need to see the layout of the data.
Sorry for my english and if i am not clear (English is not my mother tongue).
Please find attached the file below.
I want to create the time to status variable as it appear in the file.
Thanks again
I realize you are new here, but I specifically stated the format needed, and that other formats are not acceptable. Many of us (including me) will not download attachments. Please show us SAS data step code that will reproduce a portion of your data set.
Here is the data step to create the table:
data tiredness;
input ID $ Day_1 Day_2 Day_3 Day_4 Day_5 status;
datalines;
1 50 60 70 85 20 1
2 10 20 30 . . 0
3 20 40 50 55 60 0
4 85 79 100 120 130 1
;
run;
I want to create a new variable time_to_status which will take the following values:
4 , 3, 5,1 for individus 1,2,3,4 respectively.
Great! Thank you.
data want;
set tiredness;
array d day_1-day_5;
do i=1 to dim(d);
if d(i)>=80 then do;
time_to_event=i;
leave;
end;
if time_to_event=. then time_to_event=n(of d(*));
end;
run;
Thank you for your quick reply :).
I am at home for the moment (France) so i will test it tomorrow.
For individuals with non missing missing values and and status=0 does the code will increment for time_to_status the last day of follow up?
@Romain69100 wrote:
Thank you for your quick reply :).
I am at home for the moment (France) so i will test it tomorrow.
For individuals with non missing missing values and and status=0 does the code will increment for time_to_status the last day of follow up?
It does this: "I want to create a new variable time_to_status which will take the following values: 4 , 3, 5,1 for individus 1,2,3,4 respectively."
Great. Please mark the reply with the working code as correct, instead of marking the reply with a brief comment as correct.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.