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: tabout and foreach -counter error
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: tabout and foreach -counter error
Date
Wed, 7 Dec 2011 10:21:40 +0000
Stata uses low-ASCII characters for right-single quote, left single
quote and double quote.
. di char(39)
'
. di char(96)
`
. di char(34)
"
I think these arguments for the -char()- function are invariant under
operating system, but I haven't checked.
Examples of correct usage in your code are
local heading = ""
if `counter' > 0
Most of the other uses of quotation marks are incorrect.
Check out -asciiplot- (SSC) for a guide to -char()- on your system.
Nick
On Wed, Dec 7, 2011 at 8:41 AM, Nick Cox <[email protected]> wrote:
> And in addition you seem to have all sorts of irregular variations on
> ` ' (left single quote ... right single quote) to refer to local
> macros. There is one and only one way to refer to local macros, the `
> character before the name and the ' character after the name.
>
> Nick
>
> On Wed, Dec 7, 2011 at 8:39 AM, Nick Cox <[email protected]> wrote:
>> This looks like a confusion between the numeral 1 (one) and the letter l.
>>
>> I
>>
>> Nick
>>
>> On Wed, Dec 7, 2011 at 6:00 AM, Claudia Y. Rangel <[email protected]> wrote:
>>
>>> I am trying to replicate the example in Dr. Watson's tabout tutorial
>>> to produce tables for 25 variables with restricted data, repeated over
>>> 30 geographical units; hoping to reduce my lengthy do file code. I am
>>> sure there is a problem with the special characters and after trying
>>> to use (') (`) and (') I still got an error returned about the counter
>>> variable.
>>>
>>> My apologies for any stata 101 coding mistakes.
>>>
>>>
>>> levelsof lipsname, local(levels)
>>> local lipslabels : value label lipsname
>>> local counter = 0
>>> local filemethod = "replace"
>>> local heading = ""
>>>
>>> foreach 1 of local levels {
>>> if `counter' > 0 {
>>> local filemethod = ”append”
>>> local heading = ”h1(nil) h2(nil)”
>>> }
>>> local vlabel : label ’lipslabels’ ’l’
>>>
>>> qui tabout var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11
>>> var12 var13 var14 var15 var16 var17 immigrant if lipsflag==1 & if
>>> lipsname == ’l’ using ”tablesfile.txt”, ’filemethod’ ///
>>> cells (freq row) show(all) layout(cb) stats(chi2) ’heading’
>>> h3(”LIPS: ’vlabel’”) f(0c) ptotal(single)
>>> local counter = `counter' + 1
>>> }
*
* 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/