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 at the end of May, 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 <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: tabout and foreach -counter error
Date   Wed, 7 Dec 2011 15:31:09 +0000

If I can toot a toy trumpet: -asciiplot- (SSC) is in some ways a characteristic product of Statalist, as it emerged from posts and code fragments flying around the list. I doubt the three authors have ever been in the same room, although I've met both of the other two. I use it frequently myself to clarify questions on awkward characters. 

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


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Claudia Y. Rangel
Sent: 07 December 2011 15:19
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: tabout and foreach -counter error

Thanks a lot for this much needed information.

Claudia

On Wed, Dec 7, 2011 at 5:21 AM, Nick Cox <njcoxstata@gmail.com> wrote:
> 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 <njcoxstata@gmail.com> 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 <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
>>>> }
>
> *
> *   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/

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