Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: levelsof


From   "Ben Jann" <ben.jann@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: levelsof
Date   Fri, 21 Sep 2007 09:42:46 +0200

The macro "levels" is undefined in your code. For example, type

  levelsof YY, local(levels)

ben

On 9/21/07, Luhang Wang <luhang@gmail.com> 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/



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