Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: More elegant code . . .?


From   Richard Williams <[email protected]>
To   [email protected], statalist <[email protected]>
Subject   Re: st: More elegant code . . .?
Date   Sat, 04 Jun 2011 21:39:21 -0500

Is 0 the smallest possible value, and are all cases non-missing? (Or else missing for all 10 vars?) Then try

recode letter_auto_stop 0=1 if max(letter1,letter2,letter3,letter4,letter5,letter6,letter7,letter8,letter9,letter10)==0


At 06:18 PM 6/4/2011, Michael Costello wrote:
Statalisters,

I have some code that I would like to make more elegant (shorter,
while still fitting on one line):
recode letter_auto_stop 0=1 if letter1==0 & letter2==0 & letter3==0 &
letter4==0 & letter5==0 & letter6==0 & letter7==0 & letter8==0 &
letter9==0 & letter10==0

The line above works, but it's bulky.  I'd like to find something
better to use.  I tried:
recode letter_auto_stop 0=1 if letter1-letter10==0

but stata treated it as "recode letter_auto_stop 0=1 if letter1==0 &
letter10==0" ignoring letter2 through letter9 entirely.

Thanks for any help you can provide!
-Michael

--
Michael Costello
Mathematics & Statistics Teacher, Bethesda-Chevy Chase High School
Intern, RTI International

"To call in the statistician after the experiment is done may be no
more than asking him to perform a post-mortem examination: he may be
able to say what the experiment died of."  -Sir Ronald Aylmer Fisher,
FRS

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

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW:    http://www.nd.edu/~rwilliam

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index