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: Adding a blank space at the end of a variable in preparation for reclink


From   Matthew Krauchunas <[email protected]>
To   [email protected]
Subject   Re: st: Adding a blank space at the end of a variable in preparation for reclink
Date   Sun, 1 Aug 2010 22:39:30 -0400

Tirthankar,

That worked perfectly. Thank you!

On Sun, Aug 1, 2010 at 10:29 PM, Tirthankar Chakravarty
<[email protected]> wrote:
> You should try regular expressions. Stata's implementation should be
> sufficient for your purposes. For example, "$" anchors to the end of
> the string:
>
> ****************************************
> clear
> input str20 street_names
> "something st"
> "stover st"
> "boulevard blvd"
> "avenue q"
> "q ave"
> end
> li
> replace street_names = regexr(street_names, "ave$", "avenue")
> replace street_names = regexr(street_names, "blvd$", "boulevard")
> replace street_names = regexr(street_names, "st$", "street")
> li
> ****************************************
>
> T
>
> 2010/8/2 Duha Altindag <[email protected]>:
>> I think this should insert a blank to the end:
>>
>> g street_adress2=street_adress+" "
>>
>> Also, I remember existence of command that creates the mirror image of
>> a string, like "abcd" turned into "dcba". If you could convert
>> street_adress into its mirror image, sall this new variable ss, then
>> each observation in ss will start like either "ts" or "eva" or "dvlb".
>>  For example, "Staton st" will be "ts notatS". Then you can use
>> subinstr(ss, "ts", "teerts",1) will convert first "ts" in ss into
>> "teerts". Finally you can again use this mirror image command to
>> convert the variable into nice looking street adress variable.
>> Hope this helps.
>> Duha
>>
>> On Mon, Aug 2, 2010 at 12:59 AM, Matthew Krauchunas
>> <[email protected]> wrote:
>>> Hello,
>>>
>>> I am trying to clean up street addresses in preparation for a fuzzy
>>> merge via reclink.  I want to change st --> street, ave --> avenue, rd
>>> --> road etc.  I am running into a problem though as those characters
>>> are normally at the end of a string.  Thus, I cannot use commands
>>> like:
>>>
>>> replace street_address=subinstr( street_address, " st", " street ", .)
>>> replace street_address=subinstr( street_address, " ave", " avenue ", .)
>>> replace street_address=subinstr( street_address, " blvd", " boulevard ", .)
>>>
>>> Because it will change street names like "Stover" in street over.  I
>>> am thinking of adding an extra space at the end of street_address,
>>> running replace commands, and then removing the extra space via rtrim
>>> command.  Does this sound like a good plan of attack?  If so, does
>>> someone know how I can add a space the end of each of these
>>> observations?
>>>
>>> Thanks!
>>> Matt
>>> *
>>> *   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/
>>
>
>
>
> --
> To every ω-consistent recursive class κ of formulae there correspond
> recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
> belongs to Flg(κ) (where v is the free variable of r).
>
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index