Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Replace string characters disregarding the position of the character in the string


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Replace string characters disregarding the position of the character in the string
Date   Fri, 22 May 2009 13:17:39 +0100

One answer is 

replace problemvar = subinstr(problemvar, ",", ".",.) 

but there is a better one. 

The underlying problem is presumably a clash of conventions on decimal
points versus decimal commas. 

There is discussion at 

SJ-8-2  dm0036  .  Stata tip 61: Decimal commas in results output & data
input
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q2/08   SJ 8(2):293--294                                 (no
commands)
        tip on using commas as decimal separators for output
        and input

In particular -destring, dpcomma- sounds like what you really want and
gets you there in one. 

Nick 
n.j.cox@durham.ac.uk 

Ben Carpenter

I`d really appreciate if someone could help me with a little 
string problem.

I want to replace commas "," by dots ".".
The "," occurs in different positions in the string such as

29,6
9,62
389,0

I`d like to convert this data to ...

29.6
9.62
389.0

(...in order to destring the data afterwards).

Could anyone help me with this replace problem? 


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index