Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: SAS to Stata do instruction


From   "Kevin Crow - Stata Corp" <[email protected]>
To   <[email protected]>
Subject   st: Re: SAS to Stata do instruction
Date   Wed, 27 Aug 2003 14:41:16 -0700

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 the
below syntax does in SAS I believe I could recreate the results in Stata.



BY INC,LN_MAX;



Below is the do-file.



clear

local logmax = log(360)

local inc = ((1+`logmax')/499.9)

local obs = 0



generate logtime = .



local logmax = `logmax' + `inc'



forvalues i = -1(`inc')`logmax' {

            local obs = `obs' + 1

            qui set obs `obs'

            qui replace logtime = `i' in `obs'

}



gen months = exp(logtime)

gen year = months/12



Below are the results of the last three observations in Stata.





. list in 499/501



     +--------------------------------+

     |  logtime     months       year |

     |--------------------------------|

499. | 5.859931   350.7001   29.22501 |

500. | 5.873706   355.5644   29.63037 |

501. | 5.887482   360.4963   30.04136 |

     +--------------------------------+



----- Original Message ----- 
From: "Giulio Rizzoli" <[email protected]>
To: <[email protected]>
Sent: Wednesday, August 27, 2003 6:44 AM
Subject: st: SAS to Stata do instruction


> I woul'd like someone to show me
> the translation of this sas code that generates 501 time points to stata
code.
>
>
>   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;
>
> Thank-you. 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/
>


*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index