Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Steve Samuels <sjsamuels@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Too many keep statements: was: Re: st: Date: Sun, 8 Sep 2013 23:54:39 +0000 |
Date | Sun, 8 Sep 2013 20:48:05 -0400 |
You might take advantage of consecutively numbered choices with the inrange() function: .keep if inrange(typex,1,16) | inrange(typex,21,30) Next time, follow the Statalist FAQ and give your post an informative title. Steve -encode- your string variable to a corresponding numeric variable, typex, with the original names as value labels. To save typing continuation comments "///", temporarily set the statement delimiter to ";" #delim ; keep if inlist(typex, 1,2,3,4,5,6,7,8,10 11,12,13,14,15,16 /* etc. */ ); #delim cr On Sep 8, 2013, at 9:26 PM, Richard Williams wrote: Would it be easier to use -drop if-? -drop if- could also be split into multiple commands if necessary. At 06:54 PM 9/8/2013, HAKAN USLU wrote: > Hello All, > > I hope someone can help me with this problem. > I am having problem with -keep if- command. > My do file is like this; > > keep if type=="murder" | type=="theft" | type=="burglary" .... > > I have more than 200 different crime types. When I run this command Stata gives me an error saying "too many Literals r(130)" if I put all 200 crime types in my list..Is there any other way for me to perform this operation?.. > > thanks in advance > > Hakan Uslu > > * > * 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/ ------------------------------------------- Richard Williams, Notre Dame Dept of Sociology OFFICE: (574)631-6668, (574)631-6463 HOME: (574)289-5227 EMAIL: Richard.A.Williams.5@ND.Edu WWW: http://www.nd.edu/~rwilliam * * 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/ * * 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/