* In response to posting . * Date: Thu, 1 Apr 2004 15:50:24 +0200 . * Reply-To: MOSER Winfried . * Sender: "SPSSX(r) Discussion" . * From: MOSER Winfried . * Subject: file with actual date and time . * "I tried to write a macro (see below) . * . define !act () !quote(!concat($time,'.sav')) !enddefine. . * but the result is a file called "$time.sav" instead of a . * number (or something else) indicating the actual date and time. * Macro !MacEcho is used to display the macro expansion . DEFINE !MacEcho(!POS !NOEXPAND !CMDEND) ECHO !QUOTE(!CONCAT(' Call : ',!1)). ECHO !QUOTE(!CONCAT(' Result: ',!EVAL(!1))). !ENDDEFINE. * Create the macro definition, and write it to a file . INPUT PROGRAM. . STRING TIME_NOW (A17). . COMPUTE TIME_NOW = STRING($TIME,DATETIME17). . END CASE. END FILE. END INPUT PROGRAM. /* Change colon in time value to a hyphen . COMPUTE #WHERE = INDEX(TIME_NOW,':'). COMPUTE SUBSTR(TIME_NOW,#WHERE,1) = '-'. STRING MAC_TEXT(A85). COMPUTE MAC_TEXT =CONCAT("define !act ()" ,"'" ,"c:\TempStor\SPSS\",TIME_NOW,".sav" ,"' " ,"!enddefine."). PRINT / 'Macro text is:' / MAC_TEXT. WRITE OUTFILE='c:\TempStor\SPSS\2004-04-01 Moser.Mac' / MAC_TEXT. EXECUTE. Macro text is: define !act ()'c:\TempStor\SPSS\01-APR-2004 14-15.sav' !enddefine. NEW FILE. * Recover the macro definition, define the macro, and display . INCLUDE 'c:\TempStor\SPSS\2004-04-01 Moser.Mac'. 52 0 define !act ()'c:\TempStor\SPSS\01-APR-2004 14-15.sav' !enddefine. 55 0 57 0 * End of INCLUDE nesting level 01. !MacEcho !Act. Call : !Act Result: 'c:\TempStor\SPSS\01-APR-2004 14-15.sav' * Use the macro to save and reload a test file . INPUT PROGRAM. . STRING MESSAGE(A40). . COMPUTE MESSAGE='Data in file named with current time'. . END CASE. END FILE. END INPUT PROGRAM. PRESERVE. SET MPRINT ON. SAVE OUTFILE=!act. 73 0 M> SAVE OUTFILE='c:\TempStor\SPSS\01-APR-2004 14-15.sav' 74 0 M> . 75 0 M> GET FILE=!act. 76 0 M> GET FILE='c:\TempStor\SPSS\01-APR-2004 14-15.sav' 77 0 M> . LIST. 78 0 M> LIST. List MESSAGE Data in file named with current time Number of cases read: 1 Number of cases listed: 1 RESTORE. 79 0 M> RESTORE.