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

Re: st: -stylerules- updated on SSC

From   Roger Newson <>
Subject   Re: st: -stylerules- updated on SSC
Date   Thu, 14 Apr 2005 12:19:20 +0100

Re Point 1, file input and output is usually MUCH more time-consuming than in-memory operations such as checking `touse'. However, re Point 2, Richard is right, and a block of code which modifies the data *permanently* should indeed start with a single -preserve- and end with a single -restore, not-, just in case the user presses -break-.


At 01:40 14/04/2005, Richard Williams wrote:

At 04:07 PM 4/13/2005 +0100, Nick Cox wrote:
The package -stylerules- on SSC has been
updated. I started by making a few changes
in the light of Stata 9, but mostly thought
of some other things to mention while
I was doing that.
Some very good rules there Nick. I'd be curious what thoughts people have about this one:

"Avoid preserve if possible. preserve is attractive to the programmer but can be expensive in time for the user with large data files. Programmers should learn to master marksample."

Suppose I ignore that advise and instead do something like

keep if `touse'

1. Will I gain some speed, because Stata will be working with a smaller data set and won't have to repeatedly process -if `touse'- commands?

2. Isn't there a potential tradeoff between this and another rule, respect the dataset? If you don't preserve, there is a greater burden on the programmer to make sure all is well at the end of the run. But, isn't there also a greater risk if, say, the user stops the program before completion?

I suppose good, careful programmers can guarantee both speed and security of data. But, I would add the caveat that, if you are not 100% confident of your programming, you might want to favor safety over speed.

* For searches and help try:

Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
Division of Asthma, Allergy and Lung Biology
King's College London

5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
  or 020 7848 6605 International +44 20 7848 6605

Opinions expressed are those of the author, not the institution.

*   For searches and help try:

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