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: ado file help


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   RE: st: ado file help
Date   Mon, 13 Aug 2012 22:01:19 +0000

Sorry Nick, this doesn't help much. 
1. Do we not need to define varlist/namelist/anything after syntax
2. How do you put it as macro in the query. Is it going to be
syntax anything, STARTdate(str) ENDdate(str) BROKERid(numeric)   /* anything because the arguments are not varlists 
odbc load, exec("select date(read_date), count(*) from readership where source_id=`BROKER_id' and date(read_date) between '`STARTdate'' and '`ENDdate'' group by date(read_date)")
or 
odbc load, exec("select date(read_date), count(*) from readership where source_id=`anything list' and date(read_date) between '`anything list'' and '`anything list'' group by date(read_date)")

----------------------------------------
> Date: Mon, 13 Aug 2012 22:25:46 +0100
> Subject: Re: st: ado file help
> From: [email protected]
> To: [email protected]
>
> As you want to write a program, you will find it much easier to write
> it in Stata style
>
> program dd
> syntax , STARTdate(str) ENDdate(str) BROKERid(str) GRAPHtype(str)
>
> <whatever>
>
> end
>
> Nick
>
> On Mon, Aug 13, 2012 at 9:41 PM, tashi lama <[email protected]> wrote:
> >
> > I wrote a do-file a while ago with 4 arguments as follows:
> >
> > begin dofile dd.do
> > clear
> > set more off
> > args graph_type broker_id start_date end_date
> > qui odbc query indigo
> > odbc load, exec("select date(read_date) as date, count(*) as hits from readership where firm_id=`broker_id' and date(read_date) between '`start_date'' and '`end_date'' group by date")
> > if "`graph_type''=="pie" {
> > ............
> > exit
> > }
> > else {
> > ........
> > exit
> > }
> >
> > The problem with this code was because args is a positional macros, whatever I enter as `1' would be graph_type, `2' as broker_id and so on. If I enter the following
> > do dd 2011-01-01 pie 2011-01-20 6429 => stata would take 2011-01-01 as graph_type and yields error.
> >
> > This makes this code not so convenient and I would like to attempt to write a code (possible ado file with synatx) so that the code would run when
> >
> > dd graph_type="pie" start_date="2011-01-01" broker_id=6429 end_date="2011-01-20"
> > or
> > dd end_date="2011-01-20" graph_type="line" start_date="2011-01-01" broker_id=6429
> >
> > I tried but got stuck
> >
> > begin adofile dd
> > clear
> > program dd
> > syntax anything
> > qui odbc ...
> > odbc load, exec(".....
> *
> * 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