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: using varlist wildcards in anova


From   Will Hauser <whauseriii@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: using varlist wildcards in anova
Date   Sun, 04 Apr 2010 00:17:39 -0400

Hello all,
As a practical workaround I use excel to duplicate command lines and varlists and such when I cannot figure out the syntax for a stata macro. You can quickly create a list where you duplicate or 'fill' "t1993" "t1994 "t1995" in a column or row. In your case you'd probably want a horizontal list, instead of dragging down you can just drag across. In either case you can quickly get a list of your t variables running to whatever number you like (you could generate hundreds of t variables in seconds). If you cut and paste that list into a do file then the spaces will be tabs; if that presents a problem for you then quickly cut and paste it into notepad first and find/replace (ctrl h) all tabs with spaces.

I know it's not really a solution to what appears to be a problem with the anova command in stata 9 but as a practical workaround to this and other similar problems I find that excel in combination with notepad can be a lifesaver. I apologize if I'm pointing out the obvious to you experts out there.

Will


Phil Schumm wrote:
On Apr 3, 2010, at 6:25 PM, Phil Schumm wrote:
On Apr 3, 2010, at 5:45 PM, Vineet Bhagwat wrote:
Which is weird, because on my computer's Stata, "reg y t* " and any other command using the asterisk works fine, just -anova- that seems to throw the error for some reason. I'm using Stata9 on my computer if that clarifies anything.


Well, at least that narrows it down. I no longer have a version of Stata 9 on my machine, so I can't look at this issue further. Perhaps someone with Stata 9 still available (or a better memory of -anova- under version 9) might be able to add something.

One workaround would be the following (IIRC, -unab- predated Stata 9):

   unab t: t*
   anova y `t'

though upgrading, if possible, would clearly be preferable.


Ok, I must confess that this made me a bit curious, especially since my previous statement


On Apr 3, 2010, at 5:21 PM, Phil Schumm wrote:
Regardless, this isn't due to -anova-, but rather is a function of how Stata is parsing the command line.


was clearly incorrect (I also misspoke when I said "parsing the command line" -- what I should have said was "expanding the varlist"). Instead, this *does* have to do with -anova-'s syntax. I pulled an old copy of Stata 9, and sure enough, I get exactly the behavior Vineet describes.

Unfortunately, in Stata 9 -anova- was a built-in command, so we can't look at the source. However, the syntax diagram

    anova varname [term [/] [term [/] ...]] [if] [in] [weight] [,
          options]

    where term is of the form   varname[{*||}varname[...]]

suggests that -anova- was using its own approach to interpret the list of model terms, and although one could specify a model as a simple list of variables, -anova- under Stata 9 evidently didn't support varname globbing.

In sum, the workaround I gave above is your only option under Stata 9.


-- Phil

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


---
avast! Antivirus: Inbound message clean.
Virus Database (VPS): 100403-1, 04/03/2010
Tested on: 4/3/2010 11:46:56 PM
avast! - copyright (c) 1988-2010 ALWIL Software.
http://www.avast.com





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