Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Thomas Lux <tholux2000@yahoo.de> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: Optimizing recoding procedures |

Date |
Tue, 11 Dec 2012 16:56:08 +0000 (GMT) |

Dear Statalisters, I am trying to optimize my data recoding procedures (in Stata 11). With the inlist-function it is possible to reduce the syntax in such a way: gen x = 1 if z==1 replace x = 0 if x==1 | x==2 | x==3 gen x = 1 if z==1 replace x = 0 if inlist(y, 1, 2, 3) However, I am looking for functions that allow a reduction in a situation with two variables in the (second) if statement: gen x = 1 if z==1replace x = 0 if x==1 | x==2 | x==3 | y==1 | y==2 | y==3 and: geb x = 1 if z==1replace x = 0 if x==1 & x==2 & x==3 & y==1 & y==2 & y==3 Is there a way of doing this via a DIRECT function in the if statement (that is without taking the indirect route via "egen ral" respectively "egen rany")? Best, Thomas Lux University of Bremen * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Optimizing recoding procedures***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Optimizing recoding procedures***From:*Thomas Lux <tholux2000@yahoo.de>

- Prev by Date:
**Re: st: Collapse error: "Factor variables not allowed"** - Next by Date:
**Re: st: Optimizing recoding procedures** - Previous by thread:
**st: SSC Archive updates** - Next by thread:
**Re: st: Optimizing recoding procedures** - Index(es):