BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

I have the following data:

 

ID  Wk1q1  Wk1q2  wk1q3  Wk1resp  Wk8q1   Wk8q2  wk8q3 Wk8resp  Wk12q1  Wk12q2  wk12q3 Wk16q1....  

1         3             2         2            0              4            4            2           1                1              1          1          0              

2         2             2         5            0              3            4            2           1                1              1          1         0           

3         3             1         3            0              4            6            2           0                0              1          1         0               

4         3             2         5            0              4            4            2           1                0              1          1         0             

5         5             3        5            0             6            3            2            1                 0              1         1           0          

6         3             2        2            0              4            4            2            1                1             0          1           0            

 

Scores for three questions are collected for at Week 1 Week 8 Week 12 Week 16, I would like to know how long does it takes a subject to get to a score of 0 for each question (q1 q2 q3...)? How long does it take a patient to get to resp=1? Which question reaches 0 first and which one reaches last? Does q1+q2 reach 0 before q3?

 

Need the SAS codes to answer these questions! Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Please do your best to provide comprehensive, accurate information without having to be asked, so those that help you have to spent as little timw as possible. 🙂

 

This may be what you want:

 

data HAVE;
input ID    Wk1q1  Wk1q2  wk1q3  Wk1resp  Wk8q1   Wk8q2  wk8q3 Wk8resp  Wk12q1  Wk12q2  wk12q3   Wk16q1    ;
cards;
       1       3       2       2       0       4       4       2       1       1       1       1       0
       2       2       2       5       0       3       4       2       1       1       1       1       0
       3       3       1       3       0       4       6       2       0       0       1       1       0
       4       3       2       5       0       4       4       2       1       0       1       1       0
       5       5       3       5       0       6       3       2       1       0       1       1       0
       6       3       2       2       0       4       4       2       1       1       0       1       0
run;

data WANT;
  set HAVE;
  WEEK_Q1   = whichn(0,WK1Q1,WK8Q1,WK12Q1,WK16Q1);
  if WEEK_Q1 then LENGTH_Q1 = choosen(WEEK_Q1,1,8,12,16);

  WEEK_Q2   = whichn(0,WK1Q2,WK8Q2,WK12Q2,WK16Q2);
  if WEEK_Q2 then LENGTH_Q2 = choosen(WEEK_Q2,1,8,12,16);

  WEEK_Q3   = whichn(0,WK1Q3,WK8Q3,WK12Q3,WK16Q3);
  if WEEK_Q3 then LENGTH_Q3 = choosen(WEEK_Q3,1,8,12,16);
 putlog ID= LENGTH_Q1= LENGTH_Q2= LENGTH_Q3=;
run;

ID=1 LENGTH_Q1=16 LENGTH_Q2=. LENGTH_Q3=.

ID=2 LENGTH_Q1=16 LENGTH_Q2=. LENGTH_Q3=.

ID=3 LENGTH_Q1=12 LENGTH_Q2=. LENGTH_Q3=.

ID=4 LENGTH_Q1=12 LENGTH_Q2=. LENGTH_Q3=.

ID=5 LENGTH_Q1=12 LENGTH_Q2=. LENGTH_Q3=.

ID=6 LENGTH_Q1=16 LENGTH_Q2=12 LENGTH_Q3=.

 

 

View solution in original post

11 REPLIES 11
starz4ever2007
Quartz | Level 8

I have the following data:

 

ID  Wk1q1  Wk1q2  wk1q3  Wk1resp  Wk8q1   Wk8q2  wk8q3 Wk8resp  Wk12q1  Wk12q2  wk12q3 Wk16q1....  

1         3             2         2            0              4            4            2           1                1              1          1          0              

2         2             2         5            0              3            4            2           1                1              1          1         0           

3         3             1         3            0              4            6            2           0                0              1          1         0               

4         3             2         5            0              4            4            2           1                0              1          1         0             

5         5             3        5            0             6            3            2            1                 0              1         1           0          

6         3             2        2            0              4            4            2            1                1             0          1           0            

 

Scores for three questions are collected for at Week 1 Week 8 Week 12 Week 16, I would like to know how long does it takes a subject to get to a score of 0 for each question (q1 q2 q3...)? How long does it take a patient to get to resp=1? Which question reaches 0 first and which one reaches last? Does q1+q2 reach 0 before q3?

 

Need the SAS codes to answer these questions! Thanks! 

ballardw
Super User

What have you attempted so far?

starz4ever2007
Quartz | Level 8

Well i was thinking that I would need to create three new variables that indicate the time frame in association with the scores

 

so like:

 

wk1    wk8   wk12    wk16

1           8        12       16

1           8        12       16

1           8        12       16

 

and use a proc lifetest at where q1 reaches 0, q2 and so on...

 

proc lifetest data=dataset(where=(q1=1)) plots=hazard(bw=200);
time wk1*q1(0);
run;

ChrisNZ
Tourmaline | Level 20

What would the output look like for the sample posted?

Please ensure the result you are posting is perfectly correct.

 

starz4ever2007
Quartz | Level 8

If I am not mistaken, the result will be a Kaplan meier curve (Cox proportional hazard model)....

 

I am just unsure how to create the code based off my variables to acheive the curve...

ChrisNZ
Tourmaline | Level 20

Sorry, let me rephrase.

What would the columns and calculated values be for the desired calculations on the sample provided?

starz4ever2007
Quartz | Level 8

length_q1     length_q2    length_q3.......length_resp

    8                  8                  16                     16

    8                 12                 .                         8

   12                 .                  16                        .

    8                 8                  16                       8

 

So basically for each question....I would need to know for each patient in what week they got a score of 0, as well as, when they got resp=1. Of course there will be times where the subjects did not acheive 0 by the end of the 16 weeks for 1 or more of the questions or achieve resp=1. Perhaps doing a kaplan meier model (with median achieving responding times) is the best analysis for answering my questions? But with the way by data is set up I am lost on how to SAS code it....

ChrisNZ
Tourmaline | Level 20

There is no ID column in the output provided.

If the first row is for ID=1, why isn't length_q1=16 since it seems that's the outcome (value =0) in the provided sample?

 

ID Wk1q1 Wk1q2 wk1q3 Wk1resp Wk8q1 Wk8q2 wk8q3 Wk8resp Wk12q1 Wk12q2 wk12q3 Wk16q1

1     3     2    2            4      4      2      1         1      1      0

 

 

starz4ever2007
Quartz | Level 8

you are correct. it is 16. the example of my output did not correspond accuratly to my dataset. apologies .

 

so  subj          length_q1  

         1               16

        2                16

       3                12

        4                12

ChrisNZ
Tourmaline | Level 20

Please do your best to provide comprehensive, accurate information without having to be asked, so those that help you have to spent as little timw as possible. 🙂

 

This may be what you want:

 

data HAVE;
input ID    Wk1q1  Wk1q2  wk1q3  Wk1resp  Wk8q1   Wk8q2  wk8q3 Wk8resp  Wk12q1  Wk12q2  wk12q3   Wk16q1    ;
cards;
       1       3       2       2       0       4       4       2       1       1       1       1       0
       2       2       2       5       0       3       4       2       1       1       1       1       0
       3       3       1       3       0       4       6       2       0       0       1       1       0
       4       3       2       5       0       4       4       2       1       0       1       1       0
       5       5       3       5       0       6       3       2       1       0       1       1       0
       6       3       2       2       0       4       4       2       1       1       0       1       0
run;

data WANT;
  set HAVE;
  WEEK_Q1   = whichn(0,WK1Q1,WK8Q1,WK12Q1,WK16Q1);
  if WEEK_Q1 then LENGTH_Q1 = choosen(WEEK_Q1,1,8,12,16);

  WEEK_Q2   = whichn(0,WK1Q2,WK8Q2,WK12Q2,WK16Q2);
  if WEEK_Q2 then LENGTH_Q2 = choosen(WEEK_Q2,1,8,12,16);

  WEEK_Q3   = whichn(0,WK1Q3,WK8Q3,WK12Q3,WK16Q3);
  if WEEK_Q3 then LENGTH_Q3 = choosen(WEEK_Q3,1,8,12,16);
 putlog ID= LENGTH_Q1= LENGTH_Q2= LENGTH_Q3=;
run;

ID=1 LENGTH_Q1=16 LENGTH_Q2=. LENGTH_Q3=.

ID=2 LENGTH_Q1=16 LENGTH_Q2=. LENGTH_Q3=.

ID=3 LENGTH_Q1=12 LENGTH_Q2=. LENGTH_Q3=.

ID=4 LENGTH_Q1=12 LENGTH_Q2=. LENGTH_Q3=.

ID=5 LENGTH_Q1=12 LENGTH_Q2=. LENGTH_Q3=.

ID=6 LENGTH_Q1=16 LENGTH_Q2=12 LENGTH_Q3=.

 

 

starz4ever2007
Quartz | Level 8

thank you very much! i will make sure to follow your advice for future posts!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 1755 views
  • 1 like
  • 3 in conversation