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: RE: RE: RE: RE: parsing degree minute second


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: RE: RE: parsing degree minute second
Date   Tue, 31 Jan 2012 20:49:07 +0000

Not really. There is necessarily some overlap, but most of the detail
is different.

Nick

On Tue, Jan 31, 2012 at 8:44 PM, Ben Hoen <[email protected]> wrote:
> Is this an update to the 2002 article "Speaking Stata: On getting functions
> to do the work"?
>
> I think getting a subscription to the journal would be fruitful.  I will
> have to put a req in for that.

Nick Cox

> If you care to, see
>
> SJ-11-3 dm0058  . . . . . . . . Speaking Stata: Fun and fluency with
> functions
>        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J.
> Cox
>        Q3/11   SJ 11(3):460--471                                (no
> commands)
>        a tour of easily missed or underestimated Stata functions
>
> for a terse tips and tricks tutorial on functions.
>
> (-moss- is worth a look too.)
>
> Nick
> [email protected]
>
> Ben Hoen
>
> Thanks Nick!  Using word(..) makes sense and is considerably more efficient!
>
>
> Nick Cox
>
> My principle and practice with string problems is to reach for regex
> machinery if and only if simpler tools won't suffice. (When that's not true,
> they can be very helpful.)
>
> Thus here the elements you want are the first, third, fifth words of
> -latitude- to be extracted with -word(latitude, 1)- ...
>
> I infer that all your data are in the Northern Hemisphere but if not then
> -word(latitude, -1)- extracts "N" or "S".
>
> Alternatively, for a regex convenience tool, see -moss- (SSC) and
>
> . moss lat, regex match(([0-9.]+))
>
> (A rolling -moss- gathers all strings....)
>
> Nick
> [email protected]
>
> Ben Hoen
>
> I am trying to extract portions of a string "latitude" (in degree minute
> seconds) so that I can convert it to decimal degrees.  I have not been able
> to get the extraction to work; the ".list" returns null sets for all the
> latdd* variables.  Can anyone see my error?
>
> clear all
> input str20 latitude
> "39 - 46 - 21.02  N"
> "39 - 44 - 58.66  N"
> "118 - 06 - 27.95  N"
> end
> gen latdd1=regexs(1) if regexm(latitude, "(([0-9]+)[\ - ]([0-9]+)[\ -
> ]([0-9]+[\.][0-9]+))")
> gen latdd2=regexs(2) if regexm(latitude, "(([0-9]+)[\ - ]([0-9]+)[\ -
> ]([0-9]+[\.][0-9]+))")
> gen latdd3=regexs(3) if regexm(latitude, "(([0-9]+)[\ - ]([0-9]+)[\ -
> ]([0-9]+[\.][0-9]+))")
> list
>

*
*   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