Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: tabout and foreach -counter error


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: tabout and foreach -counter error
Date   Wed, 7 Dec 2011 08:41:50 +0000

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 <njcoxstata@gmail.com> 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 <clrangel@gmail.com> 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
>> }
>>
>> I appreciate any help,
>>
>> Claudia
>>
>> *
>> *   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   |   Site index