Bookmark and Share

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: "by" option can't be command with "do" command


From   Andrew Dyck <[email protected]>
To   [email protected]
Subject   Re: st: "by" option can't be command with "do" command
Date   Tue, 11 Oct 2011 08:04:27 -0600

Hi Tuki,

Presumably, you have written a program in the do-file you are trying
to call with the -by- command. Assuming that you have written a
program of the form:

capture drop program gridSearch
program define gridSearch
    ....stuff....
end

and this program is defined in a do-file name 'gridSearch.do'

You should be able to accomplish your task by including the program in
your main do-file document like so:

include "gridSearch.do"

And then, call the program in your main document with the -by- command.

bysort hs : gridSearch

Now, the last assumption here is that you have defined your gridSearch
program to be -byable-. There is a good amount of information online
about writing Stata programs to cover this part. I'd take care to test
these programs quite a bit though to make sure it's doing what you
think it's doing.

Good luck!

Andrew

On Mon, Oct 10, 2011 at 7:55 AM, Tuki <[email protected]> wrote:
> Dear all,
>
> I encountered a problem in running a grid-search program for each group of
> hs-classified observations in my dataset. For example, there are five values
> (10290,10420,10511,10519,10591) of “hs” in the following dataset, how can I
> run the grid-search program for each group of the five different values?
> Additionally, I tried to write command “by hs:….” to run my grid-search
> program for each hs-classified group, unfortunately, the program failed to
> run because the debug reminded me that “by” can’t be combined with “do
> file”. Can somebody help with this problem?  Thank you very much!
>
> hs      country cusval  quantity        product t
> 10290   736     283.731 141             57894   14
> 10420   826     10.615  1.375           71228   6
> 10511   276     78               2.687  18150   9
> 10511   528     196.735 3.278           40015   15
> 10511   818     148.753 11.0796 70071   9
> 10511   251     4.861              .718 14568   8
> 10519   276     6.189              .718 18151   7
> 10519   276     9.396           .621    18151   5
> 10519   404     7.355              .636 32462   4
> 10591   682     10.8318    .812 46729   12
> 10591   528     9.09482    .636 40017   8
> 10591   276     8.49024    .417 18152   9
>
>
>
> --
> View this message in context: http://statalist.1588530.n2.nabble.com/by-option-can-t-be-command-with-do-command-tp6876955p6876955.html
> Sent from the Statalist mailing list archive at Nabble.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/
>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index