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

st: RE: -tempvar- not dropped after -save-


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: -tempvar- not dropped after -save-
Date   Mon, 12 May 2003 18:44:49 +0100

Daniel Muller
>
> I have a (part of a) small program, where I create
> -tempvar-s. However,
> the -save- keeps these temporary variables in the saved
> file. What am I
> missing here?
>
> ---------------
> prog def spatsam
> 	version 8.0
> 	syntax , Gap(int) Xc(str) Yc(str) SAVing(str) REPLACE
> 	preserve
> 	tempvar x y
> 	gen `x'=`xc'/`gap'
> 	gen `y'=`yc'/`gap'
> 	keep if `x'==int(`x') & `y'==int(`y')
> 	save `saving', `replace'
> 	restore
> end
> ---------------

Your title should be, I guess, not dropped
before -save-.

Temporary variables persist for the lifetime
of a program or until you -drop- them.

Hence you need to -drop- before you -save-.

Alternatively, as presumably -xc- and -yc- are
really variable names

prog spatsam
 	version 8.0
 	syntax , Gap(int) Xc(varname) Yc(varname) SAVing(str) REPLACE
 	preserve
 	keep if (`xc'/`gap')==int(`xc'/`gap') &
(`yc'/`gap')==int(`yc'/`gap')
 	save `saving', `replace'
 	restore
end

Nick
[email protected]

*
*   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