Bookmark and Share

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: String with embedded quotes and local macros


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: String with embedded quotes and local macros
Date   Sun, 24 Mar 2013 18:02:59 +0000

You should try

display `"`text'"'

The principle is this. Double quotation marks  " " will be treated as
delimiters and stripped on display _unless_ you protect them with
compound double quotes `" "'.

Nick

Terminology tip: you issued a command, not a function.

On Sun, Mar 24, 2013 at 5:51 PM, Michael Costello
<[email protected]> wrote:

> 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.
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index