* Prostate Cancer --- Baseline data; DATA baseline; INFILE "C:\Documents and Settings\kmed\My Documents\PrCa_cases.txt" ; INPUT id t_0 MMDDYY8. psa_0 tx $ ; RUN; * Prostate Cancer --- Post-treatment PSA values ; DATA post_tx; INFILE "C:\Documents and Settings\kmed\My Documents\psa_file.txt" linesize = 189 ; INPUT id 1-8 +1 (t_1-t_20) (MMDDYY8. +1 ) / +9 (psa_1-psa_20) (8.1 +1) ; RUN; proc sort data=baseline; by id; proc sort data=post_tx; by id; * Merge the baseline and follow-up data and (at same time) create 24 new time variables; data all; merge baseline post_tx; by id; * calculate time elpsed from t_0 ; Array t(24) t_1-t_24; array fu_time(24) fu1-fu24; * new variables to hold the differences; do i=1 to 24; fu_time(i) = t(i) - t_0; end; run; * shape of <> file is WIDE ; * make the datafile LONG ; data long; * 1 observation per PSA value; keep id time psavalue; array psa(24) psa_1-psa_24; array fu_time(24) fu1-fu24; set all; do i=1 to 24; psavalue= psa(i); time = fu_time(i); if psavalue ne . then output; * put the non-missing psa values into dataset; end; proc sort data=long; by id; proc plot data=long; plot psavalue*time; by id; run;