Learner
Posts: 1

# Data manipulation for Survival Analysis

Hey everyone! I am currently going through data manipulation stage of a longitudinal (5 yr) dataset so that I can do a survival analysis. In this case I am looking at Sexual Onset (outcome) to Parenting styles. I am using SAS 9.4.

Here is my coding using do loops to create year to event (year), age of event (onset), censoring (censored). The variable I am observing for my outcome is YSAQ_299  in years '98, '99, '00, '01, '02.  The responses for this variable is 1 (yes), 0 (no), did not respond/ skipped question (-5,-3, -2, -1)

data onset;

set prnts;

year =1;

if YSAQ_299_1998 eq 1 then Onset = 14;  ***  sexual onset in 98 n= 411;

if YSAQ_299_1998 in (-5,-3, -2, -1) then Censored = 14; *** censored in 98 n= 135;

if YSAQ_299_1998 in (-4, 0) then do; *** did not have a sexual onset in 98 continue in the risk population;

year= year +1 ; **no sexual onset in 98 n= 1208;

if YSAQ_299b_1999 eq 1 then Onset = 15; *** sexual onset in 99 n=193;

if YSAQ_299b_1999 in (-5,-3, -2, -1) then Censored = 15; ** censored in 99 n =54;

if YSAQ_299b_1999 in (-4, 0) then do; *** did not have a sexual onset in 99 continue in the risk population n = 961;

year= year +1 ;

if YSAQ_299b_2000 eq 1 then Onset = 16; *** sexual onset in 00 n= 220;

if YSAQ_299b_2000 in (-5, -3, -2, -1) then Censored = 16; ** censored in 00 n=25;

if YSAQ_299b_2000 in (-4, 0) then do; *** did not have a sexual onset in 00 continue in the risk population n=716;

year= year +1 ;

if YSAQ_299b_2001 eq 1 then Onset = 17; *** sexual onset in 01 n= 211;

if YSAQ_299b_2001 in (-5, -3, -2, -1) then Censored = 17; ** censored in 01 n=22;

if YSAQ_299b_2001 in (-4, 0) then do; *** did not have a sexual onset in 01 continue in the risk population n=483;

year= year +1 ;

if YSAQ_299b_2002 in (-5, -3, -2, -1) then Censored = 18; ** censored in 02 n=14;

if YSAQ_299b_2002 = 1 then Onset = 18;

end;

end;

end;

end;

run;

1. So far I know that I have created variables of those of truly had the event and those who were truly censored. Do I have to create a variable that includes those that had the event (including those who truly had the event and those who were censored)? If so, when I perform proc logistic, how will SAS know if the subject were censored or had a true event? Is that even important?

2. I was told that I can create an "event history frequency statistics" using proc freq. How can I do that or will I have to use proc lifetest? Also, I was able to manually compute the survival probability and hazard probability for each year. How can I get that output?

Thanks!

Discussion stats
• 0 replies
• 267 views
• 0 likes
• 1 in conversation