Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Clickable examples in ado help files


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Clickable examples in ado help files
Date   Thu, 18 Sep 2003 18:44:30 +0100

Mark Schaffer
>
> A couple of questions for you:
>
> 1.  What do you think of clickable examples in a command
> help file?
> That is, if the example in the help file is
>
> ivreg2 y1 x1 x2 (y2 y3 = z1 z2 z3), gmm ffirst
>
> and you click on this line, then the command is executed.  It's
> possible to do this in smcl with {stata <command> : <text of the
> command> } , but is it worth it?

Yes. Various graph help files are examples.

> 2.  This would work only if the dataset that the example uses is in
> memory.  I tried to put a clickable command to load the data in the
> help file with the command
>
> {stata use "http://fmwww.bc.edu/ec-p/data/macro/abdata.dta";
> : . stata
> use http://fmwww.bc.edu/ec-p/data/macro/abdata.dta}
>
> where the part following the : separator is the clickable text to
> display to the user, and the "" are used because the URL
> contains a :.
>
> Unfortunately, what gets displayed is
>
> //fmwww.bc.edu/ec-p/data/macro/abdata.dta" : . use
> http://fmwww.bc.edu/ec-p/data/macro/abdata.dta
>
> (all on one line)
>
> and when I click on it, Stata tries to execute the command
>
> use "http
>
> with the following result:
>
> . use "http
> file http.dta not found
> r(601);
>
> What's happening is that Stata is ignoring the "" and treats the
> first : in the URL as the separator for the smcl command.
>
> I'm using Stata 7 (but hoping to update soon....).  Does
> this happen
> in Stata 8 too?  Any ideas on a Stata 7 (or 8) workaround?

I haven't thought of how much more difficult to do
this in Stata 7. In Stata 8 I would look at -gr_example.ado-,
which is not even -undocumented-, but fairly transparent.

In essence, I suspect that you _must_ do it indirectly.
At a minimum you have to -preserve-, read in the example dataset, do
whatever it is and -restore-. You can't do all that without bundling
it in a program. -gr_example- is a template.

Nick
n.j.cox@durham.ac.uk

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index