%macro kmplot(chemid,plotx,plotlogx,outfile); /* QQ plot of normal distribution for each & chemid */ /* to be run after %km: uses XXcdf calculated in kmest */ /* uses adjusted S(t) stored in plotsurv */ /* Input: chemid: name of variable identifying BY groups */ /* plotx: if 1, then plot normal QQ plots */ /* plotlogx, if 1, then plot log normal QQ plots */ /* outfile: filename in which to store the cdf of Y */ /* if omitted, then cdf not stored */ data XXcdf2; set XXcdf; if ix > 0 then do; /* if lowest observations are all censored, survival = 1 */ /* no information about positions in qqplot, so suppress the points */ if plotsurv = 1 then q = .; else q = probit(plotsurv); /* otherwise, set q to the normal quantile for this pt. */ x = 1/ix; lx = -log(ix); if _censor_ = 0 then output; %if "&outfile" ne "" %then %do; file "&outfile"; if q ne . then put &chemid plotsurv q x; %end; end; keep &chemid x lx q; %if &plotx = 1 %then %do; proc reg noprint; by &chemid; model x = q; output out = pred p = pq; options noovp; proc plot; by &chemid; plot x*q = '*' pq*q = '-' /overlay; title2 'QQ plots for normal distribution'; %end; %if &plotlogx = 1 %then %do; proc reg noprint data = XXcdf2; by &chemid; model lx = q; output out = pred p = pq; options noovp; proc plot; by &chemid; plot lx*q = '*' pq*q = '-' /overlay; title2 'QQ plots for lognormal distribution'; run; %end; %mend;