Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: ado Stata file

From   David Kantor <>
Subject   Re: st: ado Stata file
Date   Fri, 16 Nov 2012 14:06:26 -0500

At 11:00 AM 11/16/2012, Chiara Mussida wrote:
Dear All,
Does anybody know how to do transform a program written in a dofile
(which contains an index) in an adofile, and therefore into a Stata

A few answers have appeared. I would add...

There are a few rules that are best to stick to when creating a command. That is, while any program can be made into a command (an ado), it is recommended to follow some "good programming" rules in doing so. I often allow myself to be a bit sloppy when just creating a program as part of a do-file, but try to make it "clean" when creating a command.

Don't reference or generate specific-named variables. Instead, use tempvars or names passed via a -syntax- statement. In either of these cases, you reference the names as local macros. But this rule is sometimes violated, using names that start with an underscore. And then it is clearly documented. (Think of _merge.)

Don't clear the in-memory dataset without the user specifying a "clear" option that you put in the -syntax-. Don't -replace- values without the user specifying a "replace" option that you put in the -syntax-. (Think of the -destring- command.) Those last two items can be summarized as -- Try not to make it easy for a user to accidentally clobber data; make it so that a user needs to write specific command elements or options before a significant change in data occurs.

I'm sure there are more of these principles, and other List-members may chime in, but this should get you started.

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index