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: run stata in a batch mode using do file


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   RE: st: run stata in a batch mode using do file
Date   Wed, 19 Sep 2012 15:51:32 +0000

Thanks...But it still errs me. Could you please look into it??
/* program ado try1.ado*/
program try1
 syntax, firm(int) 
qui odbc query indigo218 //loading database indigo218
 odbc load, exec("select date, count(*) as hits from readership group by date") //generates a table with columns date and hits
 list 
tsset date 
tsline hits
end 

/*do file try1.do*/
local 0:subinstr local 0 ";" ","    //In shell, I wrote ; followed by options instead of , since stata produces error thinking , belongs to a do-file. So I am replacing here in a dofile. 
try1 `0'
exit
 
In shell 
$ stata -b do try1; firm(93619)
stata isn't happy and returns -ksh: syntax error: `(' unexpected
 
Thanks so much and please let me know if you need more information. 
Tashi 
> From: [email protected]
> To: [email protected]
> Subject: Re: st: run stata in a batch mode using do file
> Date: Mon, 17 Sep 2012 23:38:01 +0100
> 
> On Mon, Sep 17 2012, tashi lama wrote:
> 
>> Hello all, 1. It is very well documented to run stata in a batch using
>> do file without parameters. But running stata in a batch using do file
>> with parameters in nowhere to be seen. Any idea how to do it?
>>
>> In Unix would be if I have dofile mylog with two arguments firm and date
>>
>> $ stata -b do mylog.do `firm' `date'
> 
> This will almost work. If mylog.do looks like this:
> ----------------------------------------------------------------------
> args firm date
> di "Firm: `firm'; Date: `date'"
> ----------------------------------------------------------------------
> 
> then 
> 
> $ stata -b do mylog.do firmname 20120917
> 
> will produce the file mylog.log containing these lines (among others):
> ----------------------------------------------------------------------
> . do mylog.do firmname 20120917 
> 
> . args firm date
> 
> . di "Firm: `firm'; Date: `date'"
> Firm: firmname; Date: 20120917
> ----------------------------------------------------------------------
> 
>> 2. How would you run stata in a batch mode using ado file in both
>> unix and windows.
>>
>> Say I have a myjob.ado with 2 arguments as options namely firm and date
> 
> Here, you would run a do-file (e.g., runmyjob.do) that contains the line 
> -myjob firm 20120917- within it.
> 
> 
> 
> -- 
> Brendan Halpin, Department of Sociology, University of Limerick, Ireland
> Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F1-009 x 3147
> mailto:[email protected] ULSociology on Facebook: http://on.fb.me/fjIK9t
> http://teaching.sociology.ul.ie/bhalpin/wordpress twitter:@ULSociology
> *
> * 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