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]

st: Re: Problem putting enclosed double quotes (was: Problem putting enclosed brackets).


From   Amadou DIALLO <[email protected]>
To   [email protected]
Subject   st: Re: Problem putting enclosed double quotes (was: Problem putting enclosed brackets).
Date   Thu, 1 Apr 2010 12:35:45 +0100

Dear Nick,
Thanx for your answer. I have several purposes in doing that. But the
most urgent is that what I am currently doing is to pass a series of
matrices to Zurab's xml_tab (it is the code that suits most my needs
actually) and I want to preserve the labels of the modalities of my
hundreds of variables. For short labels, there is no problem. But for
long, spaced, labels, it's more complicated.

See the example below:

sysuse auto
tab  foreign rep78 , matcell(A)
loc vall : val la for
xml_tab A, rn("`: lab `vall' 0'" "`: lab `vall' 1'") // for my code rn
will be rn(`names')

Thx.

2010/4/1, Nick Cox <[email protected]>:
> The problem is with double quotation marks "", informally often known as
> (double) quotes.
>
> (The word brackets even at its most generous doesn't I think extend beyond
>
> round brackets or parentheses ()
>
> [square] brackets []
>
> and curly brackets or braces {}.)
>
> The problem is that Stata uses " " in two ways, as string delimiters and as
> literal characters. First time round, the " " are being interpreted as
> delimiters and as such stripped.
>
> Although I tried a few solutions using compound double quotes `" "' I also
> failed to get precisely what Amadou wants. So, I am tempted to change the
> question. Why do you want precisely this? I suspect that there are other
> ways of getting the same ultimate result.
>
> Nick
> [email protected]
>
> Amadou B. DIALLO, PhD.
>
> I want to have the following labels of my variables enclosed into
> encapsulated brackets but the code fails:
>
> Instead of having the following desired form:
> "Augmenté" "Inchangé" "Diminué" "Non concerné"
>
> I have :
> Augmenté "Inchangé" "Diminué" "Non concerné"
>
> I.e. stata keeps ignoring the first label value.
>
> My code is as follows:
>
> qui foreach i of local vars {
> loc vall : val la `i'
> if "`vall'" ~= "" {
>    levelsof `i', l(l)
>    foreach k of local l {
>       loc lab : lab `vall' `k'
>       loc names `names' "`lab'" // loc names `names' "`: lab `vall' `k''"
>    }
> }
> }
> di `"`names'"'
>
>
> *
> *   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/
>


-- 

Amadou B. DIALLO, PhD.

Economist (Anti-Poverty Programs - DR Congo), AFTP3, The World Bank,
Washington DC.

Director, Center for Research and Training on Adult Health and Education.
Mayotte (FRANCE). www.aprosasoma.org

*
*   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/


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