Statalist


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

AW: st: AW: Nested loops


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: AW: Nested loops
Date   Thu, 6 Aug 2009 16:28:41 +0200

<> 


Seems you used everything I gave you, apart from the parts that were only
there for demonstration purposes. If this solves your prob, I am glad. What
I wanted to say was that this looks like something that could be easily
solved with much simpler techniques. Still, if it works according to your
intentions, that is what really counts :-)



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Sarah Linde
Gesendet: Donnerstag, 6. August 2009 16:25
An: statalist@hsphsun2.harvard.edu
Betreff: RE: st: AW: Nested loops

Thank you. I used 

local shock "__31002 __31003 __31004 __31005a __31006a __31007 __31008
__31009 __31010 __31011 __31012a"
local miss "type time sev inc ass idio cop1 cop2 cop3 exp recov"

loc i 1

foreach level of local miss{
	local nextlevel "`:word `i' of `shock''"
	// di "`nextlevel'"
		gen `level'_un =(`nextlevel' == .a)
		gen `level'_uncl = (`nextlevel' == 90 | `nextlevel' == .b)
		gen `level'_miss = (`nextlevel' ==.)
		loc ++i
}

and it worked out fine. Altough the command might be a lot more complex, it
saves a lot of time and lines in the do-file. Is it not recommendable to use
it then?

Sarah
-- 
Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index