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 SET subcommands—those set explicitly and those set by default (except MEXPAND)—are saved with PRESERVE. PRESERVE has no further specifications.
  • With RESTORE, all SET subcommands are changed to what they were when the PRESERVE command was executed. RESTORE has no further specifications.
  • PRESERVE...RESTORE sequences 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 PRESERVE command saves all of the current SET conditions. If none have been specified, the default settings are saved.
  • Next, the format is set to F5.3 and descriptive statistics for V1 and V2 are obtained.
  • The second PRESERVE command saves the F5.3 format setting and all other settings in effect.
  • The second SET command changes the format to F3.0 and sets BLANKS to 999 (the default is SYSMIS). Descriptive statistics are then obtained for V3 and V4.
  • The first RESTORE command restores the format to F5.3 and BLANKS to the default, the setting in effect at the second PRESERVE. Descriptive statistics are then obtained for V5 and V6.
  • The last RESTORE restores the settings in effect when the first PRESERVE was specified.