Statalist


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

st: RE: argument string with embedded comma


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: argument string with embedded comma
Date   Wed, 10 Dec 2008 19:34:29 -0000

My experiments indicate that despite the " " or even `" "' Stata sees
the comma as indicating an option, which is not what you want. 

My only suggestion is that you define a string scalar, pass the name to
the do file and then print the string scalar contents. (A local won't
work.) Equivalently, a global would work too. 

scalar a = "whatever, wherever, whenever" 

do temp a 

The do file then starts 

args a 
di scalar(`a') 

Nick 
n.j.cox@durham.ac.uk 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Feiveson,
Alan H. (JSC-SK311)
Sent: 10 December 2008 19:17
To: statalist@hsphsun2.harvard.edu
Subject: st: argument string with embedded comma

Hi I know this has come up before, but I can't find it on the Stata
FAQ's or with -findit-. If a character string as an argument has a comma
embeded in it, how can I process it correctly? For example in -temp.do-,
below:


// temp.do
args a
noi di "`a'"


. run temp "ddfgdsf"
ddfgdsf
. run temp "ddfg,dsf"
option dsf not allowed
r(198);

But on the other hand, interactively:

. local blah "dsfgd,dsgdfg"

. di "`blah'"
dsfgd,dsgdfg

Why does this work interactively, but not as an argument in a .do file?

Al Feiveson




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

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index