Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: how to eliminate characters from string variables


From   "Radu Ban" <[email protected]>
To   <[email protected]>
Subject   st: how to eliminate characters from string variables
Date   Thu, 14 Nov 2002 14:04:49 -0500

Dear all,

I have a string variable that has observation of the type
C1.A
C1.B
C1 C
C1D
C1e

For my purposes C1.A, C1 A, C1A, and C1a are the same so I would like to
eliminate all dots "." and spaces " " and lower cases from my observations.
I noticed the subinstr, and upper, command which looks like 'my friends' but
when I try:

for var r*fcode b*fcode: replace X = upper(X)\

replace X = subinstr(X,".","",1)\

replace X = subinstr(X," ","",1);               (note that delimiter is ;)

I get the command to run over the first variable but something goes wrong
with the third command:

->  replace r1fcode = upper(r1fcode)
(3 real changes made)

->  replace r1fcode = subinstr(r1fcode,".","",1)
(61 real changes made)

->  replace r1fcode = subinstr(r1fcode," `","' `",1)\ tab r1fcode"'
Unknown function ()
r(133);

For some reason, Stata puts in a ` between the " " in the third command. Can
anyone point out my mistake here. Thanks in advance, I really appreciate
your help.

Radu Ban



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index