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: Stata does not understand some strings


From   Federico Belotti <[email protected]>
To   [email protected]
Subject   Re: st: Stata does not understand some strings
Date   Sat, 5 Oct 2013 00:04:03 +0200

Pablo, check if the following code does what you are looking for

local unos "á é í ó ú ñ Á É Í Ó Ú Ñ ü"
local doss "a e i o u n a e i o u n u"

local label ""
forvalue i = 1/13 {   // Loop to replace accents from Spanish
	local l`i': word `i' of `=regexr("`unos'", "`:word `i' of `unos''", "`:word `i' of `doss''")'
	local label "`label' `l`i''"
}

di "`label'"

HTH
Federico

On Oct 4, 2013, at 6:19 PM, Pablo Bonilla wrote:

> Dear Statalist,
> 
> 
> 
> I have a problem the following problem: I wrote a program that is
> meant to remove all special Spanish accents from strings so I can have
> a clean sentence to compare it with other strings. My program has the
> following lines:
> 
> 
> 
> ***************
> 
> local unos "á é í ó ú ñ Á É Í Ó Ú Ñ ü"
> 
> local doss "a e i o u n a e i o u n u"
> 
> 
> 
> forvalue i = 1(1)13 {   // Loop to replace accents from Spanish
> 
>                        local uno : word `i' of  `unos'
> 
>                        local dos : word `i' of   `doss'
> 
>                        local label :       subinstr local label
> "`uno'" "`dos'", all
> 
> }
> 
> ******************
> 
> However it is not replacing the accents because, when I looked at the
> trace, Stata is understanding something totally different. Like this:
> 
> ***********************
> 
>      - local unos "á é í ó ú ñ Á É Í Ó Ú Ñ ü"
> 
>      - local doss "a e i o u n a e i o u n u"
> 
>      - forvalue i = 1(1)13 {
> 
>      - local uno : word `i' of `unos'
> 
>      = local uno : word 1 of á é í ó ú ñ Á É Í Ó Ú Ñ ü
> 
>      - local dos : word `i' of `doss'
> 
>      = local dos : word 1 of a e i o u n a e i o u n u
> 
>      - local label : subinstr local label "`uno'" "`dos'", all
> 
>      = local label : subinstr local label "á" "a", all
> 
>      = local label0 : subinstr local label0 "á" "a", all
> 
> -          }
> 
> ************************
> 
> As you can see Stata reads “á”  instead of “á” and so on. Do you have
> any idea why it is happening? And, more importan, do you know how to
> solve it ?
> 
> 
> 
> Thank you so much.
> 
> 
> -- 
> ----
> 
> Pablo Bonilla
> 
> *
> *   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/

-- 
Federico Belotti, PhD
Research Fellow
Centre for Economics and International Studies
University of Rome Tor Vergata
tel/fax: +39 06 7259 5627
e-mail: [email protected]
web: http://www.econometrics.it


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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index