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

RE: st: Avoiding specific values in a local variable


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Avoiding specific values in a local variable
Date   Fri, 31 Oct 2003 10:38:40 -0000

Scott Merryman replied to Dev Vencappa
> 
> > forvalues x=3111/3909{
> > twoway (line relwage year, sort)  if isic==`x'
> > }
> >
> > I have a panel data set with coded industries, the first 
> and last codes being
> 3111 and 3909 respectively. In actual fact, there are only 
> about 80 industries
> in total  rather than 799 (3909 minus 3111). Is there a way 
> I can ask Stata to
> avoid the remaining 719 industries when looping the command 
> over each industry,
> as non-existing industries would produce a blank graph and 
> would make the
> looping time-consuming. I know that one option would be to 
> define a local of the
> 80 industries, but I am sure there is another more 
> straightforward way which I am not aware of.
 
> Use -levels-
> 
> something like this should work:
> 
> levels isic, local(levels)
> foreach l of local levels {
>     twoway (line relwage year, sort)  if isic== `l'
>     }
> 

See this in context at 

Is there a way to tell Stata to try all values of a 
particular variable in a foreach statement without specifying them?
http://www.stata.com/support/faqs/data/foreach.html

Nick 
[email protected] 

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