Statalist


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

st: Re: How to eliminate the double quotes surrounding letters?


From   "Joseph Coveney" <jcoveney@bigplanet.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: How to eliminate the double quotes surrounding letters?
Date   Sat, 29 Aug 2009 17:41:00 +0900

Rose wrote:

I have a localname xy containing some letters among which there is space.

And I want rename a variable the localname xy. Due to the space, I took the 

-subinstr- funtion to eliminate the space. However, that treatment produced 

double-quotes surrounding the letters. How to deal with it?


To make what I said clear, I take an example below.

local xy "ab cd ef"

rename variable subinstr("`xy'"," ","",.)


Based on the typing above, Stata gives an error message "( not allowed r(101)".

--------------------------------------------------------------------------------

Use `=. . .' to evaluate the function.  See example below for details.

Joseph Coveney

. sysuse auto
(1978 Automobile Data)

. keep make

. local xy "ab cd ef"

. rename make `=subinstr("`xy'"," ","",.)'

. describe

Contains data from C:\Program Files\Stata11\ado\base/a/auto.dta
  obs:            74                          1978 Automobile Data
 vars:             1                          13 Apr 2009 17:45
 size:         1,628 (99.9% of memory free)   (_dta has notes)
--------------------------------------------------------------------------------
------------------------
              storage  display     value
variable name   type   format      label      variable label
--------------------------------------------------------------------------------
------------------------
abcdef          str18  %-18s                  Make and Model
--------------------------------------------------------------------------------
------------------------
Sorted by:  
     Note:  dataset has changed since last saved

.



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