Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: String Variable


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: String Variable
Date   Wed, 08 Jun 2011 10:17:55 -0400

try this

gen byte newvar=strpos(string variable,"A")>0

substitute the name of your string variable for "string variable"

Rich

On 6/8/11 10:08 AM, yj wrote:
> Hello, I'm a new user of STATA. 
> 
> I would like to generate a new variable if a concatenated string variable
> contains the character I want.
> 
> eg. 
> 
> observation            string variable
> 1                          ABC
> 2                          BC
> 3                          AC
> 4                          AFC
> 5                          A
> 
> I would like to create a new variable for observations where the string
> variable contains the letter A (its position in the string variable is
> irrelevant).
> 
> Please help, thank you!
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index