The macro "levels" is undefined in your code. For example, type
levelsof YY, local(levels)
ben
On 9/21/07, Luhang Wang <[email protected]> wrote:
> Dear all,
>
> I'm trying to take some strings out of a string variable. Suppose data
> set Y contains the list of strings, named variable YY, that I want to
> take out from a string variable XX in data set X. An example is that
> YY takes value "a" and "b", and XX takes "ac" and "bd", the results I
> want are "c" and "d".
>
> My code is as following:
>
> ***************************************************
> use Y,clear
> levelsof YY
>
> use X,clear
> foreach l of local levels {
> replace XX=subinstr(XX,"`l'","",.)
> }
>
> **************************************************
> It doesn't work. Could someone tell me what is wrong with my code? Or
> is there better method achieving this? Many thanks in advance.
>
> Cheers,
> Luhang
> *
> * 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/
>
*
* 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/