[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: SAS to Stata do instruction
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
>> 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
>> 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
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
The SAS author is EH Blackstone, the guru of the Hazard procedure.
* For searches and help try: