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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
st: Re: replace if and too many literals error |

Date |
Sat, 28 Feb 2009 10:05:47 +0100 |

<>

******* clear* input str20 mystring thisisonestring thisisasecondstring thisisathirdstring end local myif "strmatch(mystring,"string_1") " forv i=2/50{ local myif "`myif' | strmatch(mystring,"string_`i'")" } ma di replace mystring="string_standard" if `myif' ********

HTH Martin _______________________

To: "Statalist" <statalist@hsphsun2.harvard.edu> Sent: Saturday, February 28, 2009 12:41 AM Subject: st: replace if and too many literals error

Here's a simple problem I bet many novices like me have encountered. I want to standardize the values of a string variable in my data called "labtest." The approach I'm taking is this: replace labtest="string_standard" if strmatch(labtest,"string_1") | strmatch(labtest,"string_2") | ... | strmatch(labtest,"string_N") Where strings 1 through N are unwanted variants of the standard string I'm trying to impose. When N (the number of logical conditions above) is larger than 13, I get the error message "too many literals." But the system limit for number of string literals in an expression is 512, and the limit for numeric literals is supposed to be 300. (For my version, IC v10.) Both limits are much larger than 13. 1. What's the problem? 2. Is there a more elegant way to standardize messy string variables? (Mine are write-in responses from a survey.) Thanks for your consideration. * * 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/

**References**:**st: replace if and too many literals error***From:*Matthew Hamilton <mwhamilton@gmail.com>

- Prev by Date:
**Re: st: AW: LSDV vs. FE** - Next by Date:
**RE: st: Re: xtmelogit post-estimation** - Previous by thread:
**st: replace if and too many literals error** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |