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

st: Re: replace with many if conditions


From   baum <[email protected]>
To   [email protected]
Subject   st: Re: replace with many if conditions
Date   Tue, 10 Sep 2002 09:00:22 -0400

--On Tuesday, September 10, 2002 2:33 -0400 Iwan wrote:

dyadic operators (return code 130). This is quite frustrating in large
data sets when, for example, using replace with many if conditions.
So to debug one hase to split command lines.
It's not a real problem, but did anyone else faced this constraint?
Do you know if there are plans at STATA to relax the constraint?
It is often better to deal with this 'replace with many if conditions' in a different manner. There are a couple of FAQs that suggest how this might better be done:

http://www.stata.com/support/faqs/data/selectid.html (see point #3)
http://www.stata.com/support/faqs/data/characteristics.html

In your case a way to do this would be to create a dataset containing the values that trigger a replace, and the desired result values, and then merge that on to your dataset. Then one replace command would do it (e.g. the desired result would be missing where it is not indicated, so a replace 'if desired<.' would modify the original variable to the desired value for only those cases where the match occurs.

This method is much more reliable than having very lengthy replace/keep/drop statements, and is much more Stataish.

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