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

Re: st: clear and clear all

From   Jeph Herrin <>
Subject   Re: st: clear and clear all
Date   Mon, 03 Aug 2009 12:42:53 -0400

FWIW I've used the following for a few years without problem; this
is part of a script which is called by WinXP to open a datafile
when I double click on it - I always request 50% overhead.

	if (strpos("`1'",".dta")>0) {
		d using "`1'", short
		local size = int(r(width)*r(N)*1.5/(2^20))
		local size = max(10,`size')
		set mem `size'm
		use "`1'"

the first condition is because the same script is used to run -do-files.


Stas Kolenikov wrote:
So why exactly do you want to -use- a data set, and then -clear- it
away without doing anything to the data?

What might be really cool is to have something along the lines of

use varfile, clear overhead(30) min(10m)

so that behind the curtain Stata would:
1. -clear all-
2. look at the size of varfile on disk
3. -set mem max( (100+overhead)% of the file size, 10m )-
4. -use varfile-

The second step is actually quite complicated. -dir- aka -ls- do not
return anything Stata could understand; the -file- suite in either
Stata or Mata does not have that functionality, either; undocumented
-st_freadsignature()- in Mata cannot really look up the size of the
data file yet as the header it describes has not yet been implemented
for dta files. A working solution is to -describe using varfile- from
which you can figure out the size of the data matrix -r(width)*r(N)-
in bytes. There's still the header of the file with labels, chars and
such that takes some space, too, but the total size of the file is not
returned by -describe-.

On Sun, Aug 2, 2009 at 4:52 AM, Fred Wolfe<> wrote:
A minor suggestion for Stata 11.

As Stata 11 requires -clear all- before -set mem-, breaking many older
do files for me, I tried this sequence:

. use varfile,clear all
option all not allowed

. use varfile,clear
. clear all
. set mem 1000m

If -clear- is an option to -use-, perhaps Statacorp could also make
-clear all- an option to use.


Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
NDB Office  +1 316 263 2125 Ext 0
Research Office +1 316 686 9195

*   For searches and help try:

*   For searches and help try:

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