Statalist


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

st: AW: Quotes for scalar within local (was efficiently run three loops (or do without them))


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Quotes for scalar within local (was efficiently run three loops (or do without them))
Date   Tue, 14 Apr 2009 09:34:27 +0200

<> 

I think your problem could be solved more succinctly as

*************
sysuse auto, clear
statsby, by(rep78 foreign) clear : sum mpg
list, noobs
*************

On the delayed evaluation thing, note Nick`s
http://www.stata.com/statalist/archive/2008-06/msg01028.html



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ronnie
Babigumira
Gesendet: Dienstag, 14. April 2009 08:00
An: statalist@hsphsun2.harvard.edu
Betreff: st: Quotes for scalar within local (was efficiently run three loops
(or do without them))

Thanks
Exploring your suggestion but wanting to put the checks in a macro rather
than a variable, however,
I am stuck (I have checked the archives but I cannot find a solution)

An illustration using the auto data

local x "foreign == `i' & rep78 == `j'"
sysuse auto, clear
levelsof foreign, local(source)
foreach i of local source {
	levelsof rep78 if foreign == `i', local(rep)
		foreach j of local rep {
			sum mpg if `x'
			}
}	

I have set the trace on and this is where it fails
- sum mpg if `x'
= sum mpg if foreign ==  & rep78 ==

Looks like the `i' and `j' disappear. I have fiddled around with different
combinations of quotes
but no luck.

Ronnie



Roy Wada wrote:
>>
>> gen check=1 if fup_pdt>`x' | fup_unit=`Y' | fup_qtycoll`x' & fup_unit=`Y'
& fup_qtycoll
> 
> where x, y, z are some conditions to be met. Then you would list them,
i.e.
>  
> list fup_pdt fup_unit if check==1
> 
> And you'll know they aren't good at all.
>  
> _________________________________________________________________
> Windows Live?: Keep your life in sync.
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009
> *
> *   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/


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