|
Hi,
I'm trying to save an output file and have spss automatically name the file using today's date. Does anyone know how to do that? I tried running a macro to call the system variable $DATE, but it only calls the string "$DATE", vs the actual date, like 2/4/09. I know this can be done in SAS with symget, I'm just trying to find a way to do it in SPSS. This is the code I was running: DEFINE TEST(var1 = !TOKENS(1)) OUTPUT SAVE OUTFILE=!QUOTE(!CONCAT("c:\work\",!var1,".SPS")). !ENDDEFINE. TEST var1 = $DATE. and this is what I was getting: OUTPUT SAVE OUTFILE=c:\work\$DATE.SPS". Thanks, Francine ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
This should achieve what you want, however if you have PYTHON and the
programmability plug-in, there are even more elegant ways that you could takle this: HTH, Jason DEFINE SAVE_VIEWER() . DATA LIST /COMMAND (A255) . BEGIN DATA OUTPUT SAVE OUTFILE = 'R:\Report @@.spv' . END DATA . DATASET NAME SaveViewer WINDOW=FRONT. COMPUTE command = REPLACE(command, "@@", $DATE) . EXECUTE . DATASET CLOSE SaveViewer . !ENDDEFINE . FREQUENCIES gender jobcat . * Now save the viewer document . SAVE_VIEWER . On Thu, Feb 5, 2009 at 9:01 AM, Francine <[hidden email]> wrote: > Hi, > > I'm trying to save an output file and have spss automatically name the file > using today's date. Does anyone know how to do that? I tried running a > macro to call the system variable $DATE, but it only calls the string > "$DATE", vs the actual date, like 2/4/09. I know this can be done in SAS > with symget, I'm just trying to find a way to do it in SPSS. > > This is the code I was running: > DEFINE TEST(var1 = !TOKENS(1)) > OUTPUT SAVE OUTFILE=!QUOTE(!CONCAT("c:\work\",!var1,".SPS")). > !ENDDEFINE. > > TEST var1 = $DATE. > > and this is what I was getting: > > OUTPUT SAVE OUTFILE=c:\work\$DATE.SPS". > > Thanks, > Francine > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Hi,
The Python code below will save the file using a date in ISO format, e.g. 20090205 for today. import time, spss now = time.strftime("%Y%m%d") spss.Submit("save outfile = 'd:/temp/somename_%s.sav'." % now) Cheers!! Albert-Jan ----- Original Message ---- From: Jason Burke <[hidden email]> To: [hidden email] Sent: Thursday, February 5, 2009 8:17:04 AM Subject: Re: save an SPSS output file automatically using today's date This should achieve what you want, however if you have PYTHON and the programmability plug-in, there are even more elegant ways that you could takle this: HTH, Jason DEFINE SAVE_VIEWER() . DATA LIST /COMMAND (A255) . BEGIN DATA OUTPUT SAVE OUTFILE = 'R:\Report @@.spv' . END DATA . DATASET NAME SaveViewer WINDOW=FRONT. COMPUTE command = REPLACE(command, "@@", $DATE) . EXECUTE . DATASET CLOSE SaveViewer . !ENDDEFINE . FREQUENCIES gender jobcat . * Now save the viewer document . SAVE_VIEWER . On Thu, Feb 5, 2009 at 9:01 AM, Francine <[hidden email]> wrote: > Hi, > > I'm trying to save an output file and have spss automatically name the file > using today's date. Does anyone know how to do that? I tried running a > macro to call the system variable $DATE, but it only calls the string > "$DATE", vs the actual date, like 2/4/09. I know this can be done in SAS > with symget, I'm just trying to find a way to do it in SPSS. > > This is the code I was running: > DEFINE TEST(var1 = !TOKENS(1)) > OUTPUT SAVE OUTFILE=!QUOTE(!CONCAT("c:\work\",!var1,".SPS")). > !ENDDEFINE. > > TEST var1 = $DATE. > > and this is what I was getting: > > OUTPUT SAVE OUTFILE=c:\work\$DATE.SPS". > > Thanks, > Francine > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
