[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Does Blasnik's Law apply to -use-?

From   "Newson, Roger B" <[email protected]>
To   <[email protected]>
Subject   st: Does Blasnik's Law apply to -use-?
Date   Wed, 12 Sep 2007 15:03:04 +0100

I have a query re Blasnik's Law, first named in the Statalist archives
by Nick Cox at
which states that using the -in- qualifier uses less computing time than
the equivalent -if- qualifier. For instance

regress mpg weight in 53/74

uses less time than

regress mpg weight if _n>=53 & _n<=74

because Stata does not have to check every observation in the dataset in
memory the first way, but has to do so the second way. My query is: Does
Blasnik's Law apply to the -use- command? That is to say, does the

use mybigdata.dta in 3959/4030

use much less computing time than the statement

use mybigdata.dta if _n>=3959 & _n<=4030

which should input the same data into the memory? I ask because, as I
understand it, Stata datasets are sequential-access files (unlike SAS
datasets which I understand are random-access, with the option of having
multiple indices), and this should imply that Stata has to read through
observations 1 to 3958 before reading observation 3959.

My motivation is that I wish to streamline the command -parmby-, which
currently processes multiple by-groups by inputting the whole dataset
repeatedly, using the -restore, preserve- command, and then dropping all
by-groups except one. I am trying to think of a better way.

Best wishes (and thanks in advance)


Roger Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected] 
Web page:
Departmental Web page:

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

*   For searches and help try:

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