Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Stata Journal and piece of string variables


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Stata Journal and piece of string variables
Date   Sat, 20 Nov 2004 11:22:00 -0500

In addition to Scott Merryman's reply using substr(), a more general approach along the lines of what you were trying is Stata's regular expression matching function -match(). For this example:

drop if match(automob,"*car")


Michael Blasnik
[email protected]


----- Original Message ----- From: "TEWODAJ MOGUES" <[email protected]>
To: "Stata _" <[email protected]>
Sent: Saturday, November 20, 2004 2:42 AM
Subject: st: Stata Journal and piece of string variables


<snip>.

Another question (I don't find lots of info on the search regarding
string variables): Is there a way for me to refer to a piece of string
var? Say there is a string var called -automob- with values redcar and
bluecar. Suppose I want to do something like
drop if automob == " * car"
thus gettingn rid of rows where the values are redcar or bluecar
CLearly this syntax doesn't work, but is there a way to do something in
this spirit without too complicated splitting-up of variables?

Thanks,
Tewodaj


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index