Nick,
Thanks very much for the detailed reply. That makes complete sense to me.
I am trying to do a series of 12 event studies with 50 firms. Rather
than code them in one giant do I moved to a structure with a master do
that accumulates the common information and a called do for each event
study using stata and mata to perform 50 separate regressions on each
of two explanatory variables accumulate values of interest and report
them in the results window. As I would like to have a single
consistent explanatory equation for each of the two variables over all
of the event studies, it is very time consuming to scroll through the
mata code in between each of the 12 events even if I maximize use of
the quietly command. Thus, I wanted to have the called module be a
program so I only had to scroll through the output results and that is
how I got to the ado. That being said, I could have done this more
systematically as you mention, building it slowly instead trying to
jam the entire do into an ado off the bat. As a matter of fact, that
is what I will need to do at this point going forward.
I already ordered Kit's book, though! The estimated ship date from
Stata is not until March 9th.
Thanks again,
Tom
On Sun, Feb 22, 2009 at 12:39 PM, Nick Cox <[email protected]> wrote:
>
> Whatever the rest of your code, -xtset- evidently fails because
> -NewCompanyNum- is not yet a variable. Tweaking anything else won't
> affect this fundamental problem. Either you need to create
> -NewCompanyNum- before you call -xtset- or (same thing really) you need
> to postpone the -xtset-.
>
> I am not at all clear why you want to convert this do file to a program.
> Specific calculations with specific names embedded are usually much
> better off as do files.
>
> While it's true that creation of specific variables with wired-in names
> is perfectly legal in a program, it is usually bad style.
>
> The main rationale for a program (strict sense) is the generality that
> flows from abstraction. If your embedded names are included because you
> are moving step-by-step towards a more general program, then all well
> and good, but otherwise you will get the frustration of learning several
> aspects of programming all at once, without any of the benefits.
>
> Only rarely is an effective program a do file with different top and
> tail.
>
> More positively put, it is best to learn Stata programming from really
> simple examples, even just copying very simple examples from [U] on to
> your machine and checking of your understanding one small step at a
> time.
>
> Rush ordering Kit Baum's new book is another good way....
>
> Nick
> [email protected]
>
> Thomas Jacobs
>
>
> here is the surrounding results to running with set trace on:
>
> CalledPooledModel "1143" "1148" 10 100 0 reg FYR L.FYR L(0/1).DSFinR
>
> ------------------------------------------------------------------------
> ---
> begin xtset ---
> - version 9.2
> - syntax [varlist(numeric max=2 default=none)] [,*]
> variable NewCompanyNum not found
>
> ------------------------------------------------------------------------
> -----
> end xtset ---
> (error occurred while loading CalledPooledModel.ado)
>
> CalledPooledModel is the ado and the only place in the ado program
> where NewCompanyNum is used is in the command
>
> xtset NewCompanyNum TradeDateNum
>
> so I am still left wondering if the ado processes prior to execution
> and determines that this variable does not exist and generates the
> error while loading or something else?
>
> >> I am trying to convert a called do file to an ado with little
> success.
> >> Besides inserting the program line at the top and end line at the
> >> bottom, I have made no changes to the working called do version which
> >> is executed with a number of arguments passed from the calling
> >> program. The error I keep getting is
> >>
> >> variable NewCompanyNum not found
> >> (error occurred while loading CalledPooledModel.ado)
> >>
> >> without pasting the entire program here, the variable NewCompanyNum
> is
> >> created within the ado itself with the following steps:
> >>
> >> *Create contiguous variable
> >> egen NewCompanyNum = group(CompanyNum)
> >> summ NewCompanyNum
> >> local Count = r(max)
> >> dis `Count'
> >>
> >> where CompanyNum is a numeric variable assigned to the starting
> >> company data well upstream of this program. Is there some
> restriction
> >> on creating a new variable in an ado? Do all the variables it uses
> >> have to exist prior to its execution? Thanks for any suggestion
> >> anyone might have.
>
> *
> * 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/
--
Thomas Jacobs
*
* 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/