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: keep if string for more variables


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: keep if string for more variables
Date   Wed, 11 Dec 2013 08:47:56 +0000

Here is how that question should have been asked.

% begin better question

I have one string variable -question- with values like "blue01"
"blue02" "yellow01" and so on. I want to keep all the values beginning
with "blue". I tried to use

keep if question == "blue*"

which did not work.

% end

Why that doesn't work was explained in my first reply.

How to solve it was explained by Red Owl. His reply is retained below.

Nick
[email protected]


On 11 December 2013 08:23, Nick Bornschein <[email protected]> wrote:
> Sorry for the misleading details:
>
> I have one string variable (question) with string information like blue01
> blue02 yellow01 and so on. So that's why I tried to use
>
> keep if question == "blue*"
>
> which did not work.

Red Owl <redowl@liu> wrote:

>>>>> Try:
>>>>>
>>>>> keep if substr(color,1,4)== "blue"
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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