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
daniel klein <[email protected]>
To
[email protected]
Subject
Re: st: adding spcial character(" ") in a string
Date
Wed, 25 Jul 2012 18:04:59 +0200
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/