POLMETH Archives

Political Methodology Society

POLMETH@LISTSERV.WUSTL.EDU

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Wright, Gerald C." <[log in to unmask]>
Reply To:
Political Methodology Society <[log in to unmask]>
Date:
Tue, 31 Oct 2006 16:52:31 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (107 lines)
I agree with Phil that is useful to learn perl. However, Stata has a rather extensive set of string functions which are very well documented and debugged.  Beyond those in the manual are a large set of egen functions (see help egenmore and help egenodd), many of them written by Nick Cox.  The new regex functions (Stata 9.0) are welcome addition, but to use them effectively one has to get a handle on regular expressions. 

You can do more with perl, but there is a healthy learning curve. Anything in the neighborhood of what Barry was dealing with is easily done is Stata if you already know the program.  I turned to perl when I needed more power in searching strings that spanned multiple lines. 
Jerry
****************************************
Professor Gerald C. Wright
Department of Political Science
Indiana University
Bloomington, IN 47405
Phone: (812) 855-6308 Fax: (812) 855-2027
Web Page: http://mypage.iu.edu/~wright1/
***************************************



-----Original Message-----
From: Political Methodology Society on behalf of schrodt
Sent: Tue 10/31/2006 10:26 AM
To: [log in to unmask]
Subject:      Re: [POLMETH] Stata string wildcards
 
If the Stata string functions aren't particularly well documented, you
might be better off pre-processing the data if a system that is: perl
would seem to be the logical choice. Downside is that you are using
another tool (though if you are on either Unix, Linux or Mac OS-X, perl is
probably already part of your system); upside is there are extensive
resources (both books and material on the web) dealing with perl and
regular expressions, and perl is thoroughly debugged. And at the end of
the process you know also perl (or at least enough of perl to solve your
problem).

So I'd say use perl (or some other stand-alone string processing language)
to get things to the point where Stata will make sense of your data
without invoking excessive amounts of magic, and then let Stata handle
things from there.

=============================================================================
Philip A. Schrodt             Dept of Political Science
University of Kansas          Blake Hall, Room 523
1541 Lilac Lane               Lawrence, KS   66045    USA
email: [log in to unmask]         phone: +1-785-864-9024  fax: +1-785-864-5700
Home page:                    http://people.ku.edu/~schrodt
Kansas Event Data Project:    http://www.ku.edu/~keds
New Kind of Social Science:   http://www.nkss.org/
=============================================================================

On Mon, 30 Oct 2006, Barry C. Burden wrote:

> I am trying to write some if/then statements in Stata that depend on the
> value of a string variable.  The trouble is that variable contains names
> that are not always spelled the same way or written out fully.  For
> example, in one observation the name is written as "Hoover, Herbert" but
> in another observation it has been shortened to "Hoover, Herb."  To
> capture both of these possibilities I would like to tell Stata to recode
> if y=="Hoov*" or some such thing.  Unfortunately, the user guide isn't
> clear about the use of wildcards with string variables and my own
> experiments have failed.  Perhaps this is a better question for the
> Stata users list, but I thought another political scientist who has
> worked with strings might be able to come through with a solution.
>
> Barry
>
>
>
> ----------------------------------------
> Barry C. Burden
> University of Wisconsin
> Department of Political Science
> http://mywebspace.wisc.edu/bcburden/web/
>
> **********************************************************
>             Political Methodology E-Mail List
>        Editor: Karen Long Jusko <[log in to unmask]>
> **********************************************************
>        Send messages to [log in to unmask]
>  To join the list, cancel your subscription, or modify
>           your subscription settings visit:
>
>          http://polmeth.wustl.edu/polmeth.php
>
> **********************************************************
>

**********************************************************
             Political Methodology E-Mail List
        Editor: Karen Long Jusko <[log in to unmask]>
**********************************************************
        Send messages to [log in to unmask]
  To join the list, cancel your subscription, or modify
           your subscription settings visit:

          http://polmeth.wustl.edu/polmeth.php

********************************************************** 

**********************************************************
             Political Methodology E-Mail List
        Editor: Karen Long Jusko <[log in to unmask]>
**********************************************************
        Send messages to [log in to unmask]
  To join the list, cancel your subscription, or modify
           your subscription settings visit:

          http://polmeth.wustl.edu/polmeth.php

********************************************************** 

ATOM RSS1 RSS2