Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Using While Loops to Sample Decimal Values and Stata Programming Support?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: Using While Loops to Sample Decimal Values and Stata Programming Support?
Date   Tue, 13 Jan 2009 09:19:51 +0100

Line for the server...

Re loops: See Nick`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0009


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of John Ayers
Sent: Tuesday, January 13, 2009 5:36 AM
To: [email protected]
Subject: st: Using While Loops to Sample Decimal Values and Stata
Programming Support?

Dear Statalist Members:

Please see my question embedded in the code (in all caps as a
comment). In addition, for programming is there an excellent source
that can be recommended for using loops? I am also interested in
experiences participants had taking an official Stata "netcourse" on
programing. Thanks, john

estsimp regress drinking accult asuport2 ac_sup amodel2 ac_mod ///
edu work married age, genname (dmrate)
generate ploo = .
generate pmdd = .
generate phii = .
generate x = (_n -1 in 1/101
gen dmaxis = x / 100
******IS THERE A BETTER METHOD TO DO THE ABOVE 2 LINES IN A SINGLE
LINE OF CODE?, I.E. GEN A VARIABLE .01 .02 ... .99 1.00?
setx ac_sup $simac_sup  ac_mod $simac_mod  ///
(asuport2 accult edu work married age) mean
local b = 0
while `b' <= 1 {
*****HOW DO I GET THIS TO SAMPLE 0.0 .1 .2 .3 ... .9 1.0 OR SOME OTHER
DECIMAL VALUE, INSTEAD OF ONLY 0 AND 1?*****
   setx amodel2 `b'
   simqi, genev(pii)
   _pctile pii, p(5,50,95)
   replace ploo = r(r1) if dmaxis==`b'
   replace pmdd = r(r2) if dmaxis==`b'
   replace phii = r(r3) if dmaxis==`b'
   drop pii
   local b = `b' + 1
}
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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