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


From   daniel klein <[email protected]>
To   [email protected]
Subject   Re: st: ado file
Date   Mon, 13 Aug 2012 18:11:59 +0200

Tashi,

your -clear- command is not part of the program you define. Running
the (ado-)file once, clears the memory, defines -dd- and executes it.
This happens, when you first call -dd- (given you saved the ado-file
as dd.ado, where Stata can find it - this is the answer to your second
question). Your second call to -dd- does not run the entire ado-file
again, as this would be rather slow. Instead Stata executes the
already defined program -dd-, which is now in memory, and has no
-clear- statement in it.

As Nick Cox guessed in previous posts, it seems you are writing these
kind of programs merely to learn programming, so I will not comment on
anything beyond your question here.

Best
Daniel

-- 
I am writing a simple ado-file where I am generating a dataset using
sql query and listing the variable using syntax command. Here is my
code
clear
program dd
qui odbc query indigo_dev71
odbc load, exec("select date(read_date) as date, count(*) as hits from
readership where source_id=6429 and date(read_date) between
'2011-01-01' and '2011-01-20' group by date(read_date)")
syntax [varlist]
list `varlist'
end
exit

[...]

Great. But when I run second time  .dd date
Stata returns you must start with an empty dataset. I have a "clear"
command at the top of my adofile to start with a fresh memory. Could
someone please explain? Also, does adofile name have to be identical
to the program name? Meaning, my program name here is dd. Do I have to
have a adofile dd.ado? If they could be different, how do I execute?
*
*   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