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" <>
To   <>
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 C

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 ()

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:

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