Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: AW: levelsof problem?


From   joe j <joe.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: levelsof problem?
Date   Tue, 27 Jul 2010 12:05:50 +0200

Thanks, Martin. This is not quite what I wanted; The following command
 is good enough.
egen eutotal=rowtotal(GE_F NL_F  UK_F)

The *_F variables need to be selected based on whether they belong to
eu or not (GE_F NL_F  UK_F are selected, but not US_F) (The values of
_*F variables are not based on whether eu=1 or otherwise).  But there
are many groupings, like eu, and a lot of countries, so I was looking
for an easy method to select. But it seems to me that manual selection
is the only choice.

On Tue, Jul 27, 2010 at 11:39 AM, Martin Weiss <martin.weiss1@gmx.de> wrote:
> <>
>
> You could of course -replace- to the values you want based on the -if-
> qualifier after the fact:
>
>
> *************
> egen eutotal=rowtotal(GE_F NL_F  UK_F)
> replace eutotal=. if !eu
> *************
>
>
> The reason that your second approach does not work is that Stata expects a
> -varlist- while you feed it
>
> `"GE"' `"NL"' `"PT"'_F
>
> which it cannot process. Type -ma di- to see the contents of your -macro-s.
>
>
>
> HTH
> Martin
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von joe j
> Gesendet: Dienstag, 27. Juli 2010 10:36
> An: statalist@hsphsun2.harvard.edu
> Betreff: st: levelsof problem?
>
> >From a data set roughly like the following
> clear*
> input str2 country      eu      GE_F NL_F  UK_F US_F
> US      0       1       1       1       0
> US      0       1       1       1       0
> NL      1       1       0       1       1
> IN      0       1       1       1       1
> GE      1       0       1       1       1
> GE      1       0       1       1       1
> US      0       1       1       1       0
> US      0       1       1       1       0
> US      0       1       1       1       0
> PT      1       1       1       1       1
> end
>
> I want to calculate the  row sum of all *_F variables pertaining to eu
> countries (all excluding US_F):
> egen eutotal=rowtotal(GE_F NL_F  UK_F)
>
> However, I would prefer to follow some rules in selecting the variables,
> like
>
> levels country if eu==1, local(lev)
> egen eutotal=rsum(`lev'_F)
>
> This doesn't work, however. Any pointers would be appreciated.
>
> Joe.
> *
> *   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   |   Site index