Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: adding spcial character(" ") in a string
From
"Sarah Edgington" <[email protected]>
To
<[email protected]>
Subject
RE: st: adding spcial character(" ") in a string
Date
Wed, 25 Jul 2012 14:31:43 -0700
There isn't actually a macro being used here.
Those are compound double quotes. `" is the opening quote and "' is the
closing. There's then a double quote between them.
If you don't write it that way you would have something like:
gen text1="a" + " + foobar + "
If you type that, Stata will return "a + foobar + " because it assumes that
those quotation marks delineate the string you want to add.
You need the compound double quote to get Stata to understand that you want
to insert a quotation mark.
Hope that helps.
-Sarah
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of tashi lama
Sent: Wednesday, July 25, 2012 1:25 PM
To: [email protected]
Subject: RE: st: adding spcial character(" ") in a string
Also could someone please explain the use of macro to embed quotation mark
`"""'+title+`"""'. Usually if I have to add string "tt" in front of another
string "bb", I would accomplish this by doing "tt"+"bb" instead of
`"tt"'+"hh".
----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: RE: st: adding spcial character(" ") in a string
> Date: Wed, 25 Jul 2012 19:57:09 +0000
>
> you are right. It actually works but the text are all over. I actually
found another way of doing although I picked up half od Daniel's code. I
pulled away myself from using daniel's code because I couldn't understand
bottom half of his code esp the loops. And also, the macronames identical to
varnames make it follow even difficult. Anyone willing to break down
Daniel's loop will be highly appreciated. The code I used was..
> gen text1=string(bar)+" "+string(foo)+`" ""'+foobar+`"""'
> levelsof text1, local(text) clean
> tsset foo
> tsline bar, ttext(`text')
>
> ----------------------------------------
> > From: [email protected]
> > To: [email protected]
> > Subject: RE: st: adding spcial character(" ") in a string
> > Date: Wed, 25 Jul 2012 12:30:35 -0700
> >
> > The example that Dan sent you works fine on my machine. Did you make
> > sure to clean up any carriage returns or characters that are in
> > their place in the e-mail?
> >
> > HTH,
> > Billy
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of tashi
> > lama
> > Sent: Wednesday, July 25, 2012 12:26 PM
> > To: [email protected]
> > Subject: RE: st: adding spcial character(" ") in a string
> >
> > I fail to understand the loop. Also confusing are the macro names
> > that are identical to varnames. Is that by necessity or just
> > coincidence? The program fails to run by the way. Thanx anyway.
> > ----------------------------------------
> > > Date: Wed, 25 Jul 2012 18:04:59 +0200
> > > Subject: Re: st: adding spcial character(" ") in a string
> > > From: [email protected]
> > > To: [email protected]
> > >
> > > Might be a little clumsy, but this works for me
> > >
> > > clear
> > > inp foo bar str7 foobar
> > > 23 42 "foo bar"
> > > 42 23 "foobar"
> > > end
> > >
> > > tsset foo
> > >
> > > g foobar2 = ///
> > > strofreal(foo) + " " + strofreal(bar) + `" ""' + foobar + `"""'
> > >
> > > qui levelsof foobar2 ,l(foo)
> > >
> > > forv j = 1/`: word count `foo'' {
> > > loc bar `bar' `=char(96)'`j'`=char(39)'
> > > }
> > > token `"`foo'"'
> > >
> > > tsline foo, ttext(`bar')
> > >
> > > Best
> > > Daniel
> > >
> > > --
> > > I am guessing that my two previous posts weren't clear enough for
> > > readers to respond/generate idea because I am sure there has to be
> > > a solution to this. So, I am attempting to make it as readable as
> > > possible. Here is a subset of my dataset.
> > > hits date title
> > > 23 23jan2011 Earning Report
> > > 41 04feb2011 Metamorphosis
> > >
> > > I would like to use tsline and use ttext option progrmmatically as
> > > follows. Typing manually is no issue.
> > > tsline hits, ttext(23 23jan2011 "Earning Report" 41 04feb2011
> > > "Metamorphosis")
> > >
> > > I was successful in getting above command but without character("
> > > ") inside ttext. Does someone have any idea how to do it?
> > > *
> > > * 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/
> >
> > *
> > * 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/
> >
> > *
> > * 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/
> *
> * 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/
*
* 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/
*
* 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/