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: Conditional statement with multiple string values?


From   "Cohen, Elan" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Conditional statement with multiple string values?
Date   Thu, 7 Jun 2012 20:46:33 +0000

John,

How about:

drop if inlist(lower(ACTION_NAME), "topic-viewed", "organizer-viewed", "discussion-home-viewed", "assignments-listed", "web-links-home-viewed", "folder-selected", "compile-lm")

Note that -inlist()- can only take up to 10 string arguments.

HTH,

- Elan


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Richard Goldstein
Sent: Thursday, June 07, 2012 16:40
To: [email protected]
Cc: John Whitmer
Subject: Re: st: Conditional statement with multiple string values?

your statement is illegal; better read up on the -if- expression

try using -inlist-

Rich

On 6/7/12 4:34 PM, John Whitmer wrote:
> Hello Statamasters,
> 
> I'm trying to run a conditional "drop" statement based on multiple values in a string variable.  
> 
> I tried the following command:
> 
>  drop if ACTION_NAME == "topic-viewed" | "organizer-viewed" | "discussion-home-viewed" | "assignments-listed" | "Web-Links-home
>> -viewed" | "folder-selected" | "compile-lm"
> 
> And  received the error message "too few quotes".  
> 
> My quotes are paired ... 
> 
> Alternatively, I tried the following:
> 
> . drop if ACTION_NAME == "topic-viewed" | ACTION_NAME =="organizer-viewed" | ACTION_NAME =="discussion-home-viewed" | ACTION_NAM
>> E =="assignments-listed" | ACTION_NAME =="Web-Links-home-viewed" | ACTION_NAME =="folder-selected" | ACTION_NAME =="compile-lm
>> "
> 
> And didn't get the error message, but there were 0 observations deleted - and this is a monster logfile with a lot of records with these values.
> 
> Any ideas?  And I know the severity of the drop statement ... 
> 
> Best, John
> 
>  *********************************************
> John Whitmer
> E: [email protected]
> P: 530.554.1528
> C: 530.574.8827
> Skype: john.whitmer
> Virtual Meeting Room:  http://bit.ly/rnBS8u
> 
> Discoveries & Reflections on Google+
*
*   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/


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