[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: String Manipulation Question
Thanks for both suggestions--both worked perfectly. I need the double
quotes so I can easily move data from Stata to a network analysis
application (that requires quoted strings).
On 8/5/05, Nick Cox <firstname.lastname@example.org> wrote:
> You have the correct idea on trimming: just
> use -trim()-.
> I am not clear why you want explicit double
> quotes as part of the string, but you
> can do it this way.
> sysuse auto
> 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?
> > TIA,
> > Alan
> > *
> > * 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:
> * 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: