option linesize = 100 pagesize = 9999 formdlim = '-' mprint; %let execpath = " "; %let Path = " "; %macro setexecpath; %let execpath = %sysfunc(getoption(sysin)); %if %length(&execpath) = 0 %then %let execpath = %sysget(sas_execfilepath); data _null_; do i = length("&execpath") to 1 by -1; if substr("&execpath", i, 1) = "\" then do; call symput("Path", substr("&execpath", 1, i)); stop; end; end; run; %mend setexecpath; %setexecpath; libname Out "&Path\"; proc format; value fgrp 0 = "Standard" 1 = "New"; run; data example; call streaminit(150203); beta1 = -0.2; beta2 = -0.4; do i = 1 to 200; group = rand("Bernoulli", 0.5); death = rand("Exponential")/exp(group*beta1); recurrence = rand("Exponential")/exp(group*beta2); /* event = death */ if death < recurrence then do; time = death; event = 2; end; /* event = recurrence */ else do; time = recurrence; event = 1; end; /* random censoring */ if rand("Bernoulli", 0.1) then event = 0; output; end; format group fgrp.; run; proc lifetest data = example outcif = out1; time time*event(0) / eventcode = 1; strata group / order = internal; run; proc print data = out1; run; proc sort data = example; by group time; proc sort data = out1; by group time; data out1grp; merge example out1; by group time; if time = 0 then Censor = .; if event = 0 then Censor = CIF; if event = 1 then Censor = .; if event = 2 then Censor = .; run; proc template; define style styles.plotc; parent = styles.listing; style graphfonts from graphfonts / 'GraphDataFont' = ("Arial Unicode MS, ", 9pt) 'GraphUnicodeFont' = ("", 11pt) 'GraphValueFont' = ("Arial Unicode MS, ", 11pt) 'GraphLabel2Font' = ("Arial Unicode MS, ", 12pt) 'GraphLabelFont' = ("Arial Unicode MS, ", 12pt) 'GraphFootnoteFont' = ("Arial Unicode MS, ", 12pt) 'GraphTitleFont' = ("Arial Unicode MS, ", 13pt, bold) 'GraphTitle1Font' = ("Arial Unicode MS, ", 16pt, bold) 'GraphAnnoFont' = ("Arial Unicode MS, ", 9pt); end; run; options nodate; ods listing gpath = "&Path." image_dpi = 300 style = plotc; ods graphics on / height = 18cm width = 24cm imagename = "cif_lifetest" outputfmt = png reset = index; proc sgplot data = out1grp; step x = time y = CIF / group = group; band x = time lower = CIF_LCL upper = CIF_UCL / group = group type = step fill transparency = 0.5; scatter x = time y = Censor / group = group markerattrs = (symbol = circlefilled); xaxis grid; yaxis grid; run; ods graphics off;