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]

st: String with embedded quotes and local macros

From   Michael Costello <>
To   Statalist <>
Subject   st: String with embedded quotes and local macros
Date   Sun, 24 Mar 2013 13:51:52 -0400

Hello Statalisters,

I'm trying to take some text from a spreadsheet that has embedded
double quotes (dateset 1) and convert it into a value label in another
(dateset 2). Currently I'm trying to do this by using local macros to
bridge the gap as I switch from one dataset to the other.

Let's say the long string of the value label in questions is: 1 "The"
2 "quick" 3 "brown" 4 "fox jumps over" 5 "the" 6 "lazy dog."

Yet, every time I try to run the function below, all (or almost all)
of my spaces get pushed out! Does anyone have a way that I can try to
keep these spaces still included. Specifically, I mean the spaces
between the numbers and their corresponding label values. In the end,
I will need to peel part of the value label off to be part of the
variable label, so I think the spaces become important for that
function. Also, when I do a -wordcount- function on the saying, is
there any way that I can get Stata to treat "fox jumps over" all as
one . . . um . . . word?

local text `"1 "The" 2 "quick" 3 "brown" 4 "fox jumps over" 5 "the" 6
"lazy dog.""'
display `text'
1The2quick3brown4fox jumps over5the6lazy dog.

Michael Costello

"To call in the statistician after the experiment is done may be no
more than asking him to perform a post-mortem examination: he may be
able to say what the experiment died of."  -Sir Ronald Aylmer Fisher,
*   For searches and help try:

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