Restoring SET Specifications (DEFINE-!ENDDEFINE command)
The PRESERVE and RESTORE commands bring
more flexibility and control over SET. PRESERVE and RESTORE are available generally within the
program but are especially useful with macros.
- The settings of all
SETsubcommands—those set explicitly and those set by default (exceptMEXPAND)—are saved withPRESERVE.PRESERVEhas no further specifications. - With
RESTORE, allSETsubcommands are changed to what they were when thePRESERVEcommand was executed.RESTOREhas no further specifications. -
PRESERVE...RESTOREsequences can be nested up to five levels.
PRESERVE. Store the SET specifications that are in effect at this point in the session.
RESTORE. Restore the SET specifications to what they were when PRESERVE was specified.
Example
* Two nested levels of preserve and restore'.
DEFINE macdef ()
preserve.
set format F5.3.
descriptives v1 v2.
+ preserve.
set format F3.0 blanks=999.
descriptives v3 v4.
+ restore.
descriptives v5 v6.
restore.
!ENDDEFINE.
- The first
PRESERVEcommand saves all of the currentSETconditions. If none have been specified, the default settings are saved. - Next, the format is set to
F5.3and descriptive statistics for V1 and V2 are obtained. - The second
PRESERVEcommand saves theF5.3format setting and all other settings in effect. - The second
SETcommand changes the format toF3.0and setsBLANKSto 999 (the default isSYSMIS). Descriptive statistics are then obtained for V3 and V4. - The first
RESTOREcommand restores the format toF5.3andBLANKSto the default, the setting in effect at the secondPRESERVE. Descriptive statistics are then obtained for V5 and V6. - The last
RESTORErestores the settings in effect when the firstPRESERVEwas specified.