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

Re: st: [Stata 8.2] Wanted: Improved temporary variable passing


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: [Stata 8.2] Wanted: Improved temporary variable passing
Date   Mon, 09 May 2005 15:33:04 -0500

At 01:05 PM 5/9/2005 -0700, D H wrote:
From help styleguide:

------ Very large programs become increasingly
difficult to understand, to build, and to maintain,
roughly as some power of their length. Consider
breaking such programs into subroutines and/or use a
structure of command and subcommands.

My problem:
This less-than-advanced programmer finds it difficult
to pass lots of temporary variables into Stata
(sub)programs from my master do-file.  Thus, following
the preceding advice presents a challenge.
* You might also consider the use of global macros. These are available to all programs.

* You might be able to return, sreturn or ereturn stuff you want available to your subroutines. Key thing is to be careful that these don't get zapped as you go along.

* Copy code from one subroutine to the next, where you use a similar syntax command for each routine along with, say, a bunch of local commands that give your local variable names the names you want. Get it nailed once, and then just keep copying from one routine to the next.

* One monster program isn't necessarily bad, especially when a routine or task is only done once. Put lots of ****** before and after sections so that it is clear where key sections of code begin and end.

* Get the Stata programming manual if you don't already have it. Lots of good stuff in there. You may also want the Gould et al maximum likelihood programming book.

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index