Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Compund quotes and the -file write- command


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: st: Compund quotes and the -file write- command
Date   Thu, 09 Aug 2007 17:59:46 +0100

As I understand it you want the inner compound double
quotes to be printed as characters, to be interpreted
later as delimiters, and not to be interpreted as
delimiters by -file- as it reads your command line.

I haven't tried it, but I guess that using the -char()-
function may provide a solution. That is, wherever you
would have

"

put

`=char(34)'

and so forth. -asciiplot- from SSC is one way of
seeing a list of (your version of) ASCII characters.
Royalties should be sent directly to the original authors.

Nick
[email protected]

Eva Poen

I am currently working with a large number of data sets (Stata 9)
which all have a common structure and more or less the same variables.
To ensure that variables are labeled consistently across data sets, I
wrote a little program which defines these labels from information
stored in an Access database. Everything works fine apart from one
thing: I cannot have double quotes inside my variable labels. I tried
numerous ways to incorporate compound quotes, to no avail.

The relevant code follows below. There are two variables in memory at
this point: one is called VarName; it holds all variable names for
which I want to have common labels. The other one is VarLabel which
holds the label information. The code generates a do-file which I can
then run on my data sets as required.

*************
count
local n = r(N)

file open VarLabelsFile using VarLabelsFile.do, write replace

forvalues x = 1/`n' {
file write `handle' `"capture label variable `=VarName[`x']'
"`=VarLabel[`x']'" "' _n
}

file close VarLabelsFile
*************

My attempt was to introduce compound quotes like this:
-file write `handle' `"capture label variable `=VarName[`x']'
`"`=VarLabel[`x']'"' "' _n-

But the resulting do-file still ends up looking like this:

capture label variable SessionID "zTree (or other) Session ID (alpha-numeric)"
capture label variable SID "unique Session ID (numeric)"
etc.

instead of like this:
capture label variable SessionID `"zTree (or other) Session ID
(alpha-numeric)"'
capture label variable SID `"unique Session ID (numeric)"'
etc.

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index