Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: adding spcial character(" ") in a string

From   daniel klein <>
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

inp foo bar str7 foobar
23 42 "foo bar"
42 23 "foobar"

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')


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:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index