Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

RE: st: Conditional statement with multiple string values?


From   "Cohen, Elan" <cohened@upmc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Richard Goldstein
Sent: Thursday, June 07, 2012 16:40
To: statalist@hsphsun2.harvard.edu
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: jcwhitmer@ucdavis.edu
> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index