At 02:41 PM 27-08-03 -0700, you wrote:
>I believe the below do-file should generate the data that SAS would
>generate. The only problem I could not solve was how to get the last
>observations exactly like it appeared in SAS. If you could explain
>what thebelow syntax does in SAS I believe I could recreate the results in
Stata.
>> DATA PREDICT;
>> MAX=360; LN_MAX=LOG(MAX); INC=(1+LN_MAX)/499.9;
>> DO LN_TIME=-1 TO LN_MAX BY INC,LN_MAX;
>> MONTHS=EXP(LN_TIME); YEARS=MONTHS/12
>> OUTPUT;
>> END;
>> DROP LN_TIME;
First of all thank you very much for solving the problem.
I had myself tried the forvalues loop but I was not able to figure out the
trick of adding observations within the loop (although I could start
setting obs to an arbitrary large value).
I'm also surprised that the last observation is slightly larger than the
SAS observation, and (being a surgeon) I haven't the slightest idea of the
reason.
This little do file is useful to produce a data set of evenly spaced and
progressively increasing months or years (or any other continuous
variables) to be used for out of file predictions, after an estimation
command as regress logistic or streg.
In this particular case (dealing with survivals) it sets the upper limit to
30 years=360 months and it uses logarithms so to generate more closely
spaced points in the early years (e.g. after an operation) than in the late
years.
The SAS author is EH Blackstone, the guru of the Hazard procedure.
Giulio Rizzoli
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/