- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am new to SAS and i am looking for help.
I have a dataset in wide format. Patients are followed for 20 days and each day i have tiredness measurement (20 variable per patient(day_1, day_2 ect..) and tiredness is a score between 0 and 100). I have a binary indicator (status)which is equal to 1 if tiredness is greater or equal to 80 and 0 otherwise. Using an array i would like to create a time to event variable which will take the value of the number of day when patient FIRST got a tiredness score greater or equal to 80 for those who have status=1 and the LAST number of day available in the follow up for those who have status=0.
Do you have sas script that can do it?
Thanks for your help
Romain
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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."
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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);
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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."
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Have a nice day
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Great. Please mark the reply with the working code as correct, instead of marking the reply with a brief comment as correct.
Paige Miller