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   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   Re: st: Avoiding specific values in a local variable
Date   Thu, 30 Oct 2003 19:04:19 -0600

----- Original Message ----- 
From: "Dev Vencappa" <[email protected]>
To: <[email protected]>
Sent: Thursday, October 30, 2003 6:28 PM
Subject: Re: st: Avoiding specific values in a local variable


> 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.
>
> Please help
>
> Many thanks
> Dev
>

Use -levels-

something like this should work:

levels isic, local(levels)
foreach l of local levels {
    twoway (line relwage year, sort)  if isic== `l'
    }

Hope this helps,
Scott



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