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

st: RE: st: -set memory- in Stata 11

From   "Newson, Roger B" <>
To   "''" <>
Subject   st: RE: st: -set memory- in Stata 11
Date   Mon, 27 Jul 2009 22:00:10 +0100

Thanks to Jeff for his prompt and very helpful explanation. I had been checking out earlier versions of Stata (as I still have access to both Stata 10 and Stata 9), and had noticed that the default -clear- command had downsized between its scope between Stata 9 and Stata 10. Now I know what to expect when running old do-files under Stata 11, and how best to respond.

Best wishes


Roger B Newson BSc MSc DPhil
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
Web page:
Departmental Web page:

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

-----Original Message-----
From: [] On Behalf Of Jeff Pitblado, StataCorp LP
Sent: 27 July 2009 21:06
Subject: Re: st: -set memory- in Stata 11

Roger Newson <> is using Stata 11, and has some
do-files that call -set memory- after -clear- while Stata matrices are still in

> Thanks to all at StataCorp for the new Stata 11, which I am currently
> testing (in its IC flavor) on my Windows XP system, and which seems to be
> working as advertized so far.

> One immediate query (sorry for being a pest). Is there any special reason
> why, in Stata 11, we can no longer reset the memory using -set memory- when
> there is a set of estimation results (or even a matrix) in the memory, even
> under version control with the command -version 10.1-? (I have included a
> demonstration of this feature of Stata 11 under version control below my
> signature.)

> I ask because we were always allowed to do this in Stata 6, 7, 8, 9 and 10,
> and I have therefore always habitually started most of my do-files with
> three commands, which were a -version- command, a -clear- command, and a
> -set memory- command. As in:

> version 10.1;
> clear;
> set memory 1m;

> These do-files worked under their respective Stata versions, or under higher
> versions. However, if I re-run a Stata 10.1 do-file beginning with these 3
> commands under Stata 11, and a set of estimation results (or a matrix)
> already exists in the memory, then the first 2 commands execute OK, but the
> third command aborts with the error message

> no; Stata matrices have not been cleared
> (type -clear matrix- to clear Stata matrices)

> I am aware that, if I amend the second of the above 3 commands so that they
> read

> version 10.1;
> clear all;
> set memory 1m;

> then the matrices will be cleared as well, and the do-file will therefore
> run under either Stata 10.1 or Stata 11. However, I was wondering if there
> is a quick fix to this minor teething problem which does not require me to
> edit most of my existing currently active do-files one by one. I cannot
> immediately find such a fix in the on-line help for -clear- or -memory-, or
> in the new .pdf manuals (which are a much appreciated improvement - thanks
> to all at StataCorp).

In Stata 11, matrix column/row names were updated to handle the new
factor variables notation, thus their data-structures are much more dynamic
than before.  Because of this we were faced with two competing issues:

1.  The new matrix column/row names could fragment memory making it difficult
for Stata to allocate the memory requested in a call to -set memory-.

2.  We don't want -clear- to just remove all matrices from memory because that
would result in a loss of all the estimation results currently in memory.

Thus we elected to have -set memory- complain if it found any matrices
currently stored in memory, just like it complains if there is any data or
Mata objects left in memory.

Roger has discovered the best solution by using -clear all- at the top of his

In fact, in Stata 9 and earlier and thus under version control, -clear- is
essentially the same as the modern -clear all-.  Thus, Roger should not need
to change any of his do-files from the Stata 9 days or earlier.

*   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