[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: String Manipulation Question
You have the correct idea on trimming: just
I am not clear why you want explicit double
quotes as part of the string, but you
can do it this way.
gen make2 = `"""' + make + `"""'
That is, in each case, you need
a delimiter that is `"
the character itself, "
a delimiter that is "'
The single quotes are left single
quote and right single quote.
Compound double quotes are discussed
at [U] 18.3.5.
This also works:
gen make3 = char(34) + make + char(34)
> -----Original Message-----
> From: email@example.com
> [mailto:firstname.lastname@example.org]On Behalf Of
> Alan Neustadtl
> Sent: 05 August 2005 21:47
> To: email@example.com
> Subject: st: String Manipulation Question
> Okay, I'm stumped after searching through the manuals. I have a
> string variable that has the name of a group. For example, "Stata
> Users Group" (stored without the quotes).
> I want to create a new variable that 1) trims the string, 2) adds " as
> a prefix, and 3) adds" as a suffix.
> In other programs you could do something like this:
> generate newname='"'+trim(name)+'"'
> That is, enclose the double quotes in single quotes.
> Can anyone direct me to the relevant portions of the manuals
> or know the answer?
> * 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/
* For searches and help try: