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]

st: ado file help


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   st: ado file help
Date   Mon, 13 Aug 2012 20:41:52 +0000

Hello all, 
    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(".....

Could someone provide me an idea to accomplish this? 

Thanx,
Tashi 
   

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