Hello,
I am trying to convert a SAS code provided in data documentation to Stata code and tried the following, but do not know what loop I should use as I keep getting errors or all observations dropped:
The instruction were as follows:
For time-dependent analysis, or a counting process style of input, the user would have to subset the population to those free of disease at all exams and event data would have to be modified to reflect when the event occurred relative to the examinations.
Consider the following SAS code which would modify the dataset to a counting process style of input for an analysis on the Hospitalized MI-Fatal CHD endpoint. The variable NEWEVNT is modified from MI_FCHD so that the event indicator is ‘1' only once for each participant. The variables TIME and ENDTIME define the interval the subject is at risk:
Thank you
I am trying to convert a SAS code provided in data documentation to Stata code and tried the following, but do not know what loop I should use as I keep getting errors or all observations dropped:
Code:
*Sort the dataset by RANDID in descending order and then by PERIOD. gsort RANDID -PERIOD *Initialize variables gen NEWEVNT = . gen ENDTIME = . gen EXMTIME = .
The instruction were as follows:
For time-dependent analysis, or a counting process style of input, the user would have to subset the population to those free of disease at all exams and event data would have to be modified to reflect when the event occurred relative to the examinations.
Consider the following SAS code which would modify the dataset to a counting process style of input for an analysis on the Hospitalized MI-Fatal CHD endpoint. The variable NEWEVNT is modified from MI_FCHD so that the event indicator is ‘1' only once for each participant. The variables TIME and ENDTIME define the interval the subject is at risk:
Code:
proc sort data=ANALYSIS;
by RANDID descending PERIOD;
data ANALYSIS;
set ANALYSIS;
by RANDID;
NEWEVNT=MI_FCHD;
retain EXMTIME;
if first.RANDID then do;
ENDTIME=TIMEMIFC;
EXMTIME=TIME;
end;
else do;
NEWEVNT=0;
ENDTIME=EXMTIME;
EXMTIME=TIME;
end;
proc sort data=ANALYSIS;
by RANDID PERIOD;
run;

Comment