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

RE: st: repeating same command for a number of variables


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: repeating same command for a number of variables
Date   Fri, 12 Jul 2002 10:30:26 +0100

Ulrich Kohler replied to Ronnie Babigumira

> > I am looking survey data and in this particular section,
> respondents have
> > given reasons for saving. I allow for upto four reasons and as such have
> > four variables (other1c other2c other3c other4c). Having coded all the
> > responses, I have upto 22 reasons and I would now like to flash out
> > illegal entries (exceed the codebook limits). I have a crude
> syntax (which
> > lists values greater than the codebook limit of 22 but are not missing)
> >
> > list houscode other1c other2c other3c other4c if (other1c >22 &   /*
> > */ other1c ~=.)|(other2c >22 & other2c ~=.)|(other3c > 22 & other3c /*
> > */ ~=.) |(other4c > 22 & other4c ~=.)
> >
> > Is there an easier (more elegant or less repetitive) way of doing this
>
> Don't know if this is what your looking for, but I often code things like
> that as follows:
>
> . mark touse
> . markout touse other?c
> . list houscoude other?c if touse & other1c>22 & other2c>22  /*
>    */ & other3c>22 & other3c>22
>

I don't think that is the same problem at all.

Ronnie's code -list-s observations if any of the -other?c-
is over 22 (but not missing).

Ulrich's code -list-s them only if all of the -other?c-
are over 22 (and none of them are missing).
That is much more restrictive.

In addition to my earlier suggestion, -egenmore- on SSS includes
function -rany()-, -rall()- and -rcount()-.


Nick
n.j.cox@durham.ac.uk

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index