Hello
I have a syntax which I use in different sav files. In the end of the code, I want to save the sav file with its original name but in a diferent location. I think I can change the file path with the command CD. But I do not know how to use the current file's name in OUTFILE. Thanks. Ricardo ===================== 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 |
Why not define the file name using a file
handle (FILE HANDLE)? Then you can refer to that both for opening
and saving. Since file handles are only recognized at the start of
a filespec, using CD so that you can refer to the file name without a path
is a good idea.
You could also create a macro for this, but FILE HANDLE is easier. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Ricardo Gouveia Rodrigues <[hidden email]> To: [hidden email], Date: 07/12/2013 04:46 PM Subject: [SPSSX-L] Saving using a variable outfile name Sent by: "SPSSX(r) Discussion" <[hidden email]> Hello I have a syntax which I use in different sav files. In the end of the code, I want to save the sav file with its original name but in a diferent location. I think I can change the file path with the command CD. But I do not know how to use the current file's name in OUTFILE. Thanks. Ricardo ===================== 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 |
In reply to this post by Ricardo Gouveia Rodrigues
Ricardo
You can also do it with the GUI. From the Data Editor: File > Save as The filename appears in a box in a new window: you can keep the same name or change it. Just browse to a different folder and press Save. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/spss-without-tears.html -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ricardo Gouveia Rodrigues Sent: 12 July 2013 20:40 To: [hidden email] Subject: Saving using a variable outfile name Hello I have a syntax which I use in different sav files. In the end of the code, I want to save the sav file with its original name but in a diferent location. I think I can change the file path with the command CD. But I do not know how to use the current file's name in OUTFILE. Thanks. Ricardo ===================== 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 |
In reply to this post by Jon K Peck
Thanks Jon. No dia 13/07/2013 02:07, "Jon K Peck" <[hidden email]> escreveu:
Why not define the file name using a file handle (FILE HANDLE)? Then you can refer to that both for opening and saving. Since file handles are only recognized at the start of a filespec, using CD so that you can refer to the file name without a path is a good idea. |
How are you opening the sav file? That
would be the place to define the file handle.
If you want to define the handle automatically and have installed the Python Essentials, running this code after the file is opened will do it. begin program. import spss, spssaux, os.path fn = spssaux.getDatasetInfo() spss.Submit("""FILE HANDLE mydata/NAME="%s".""" % os.path.basename(fn)) end program. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Ricardo Gouveia Rodrigues <[hidden email]> To: Jon K Peck/Chicago/IBM@IBMUS, Cc: [hidden email] Date: 07/13/2013 01:34 AM Subject: Re: [SPSSX-L] Saving using a variable outfile name Sent by: [hidden email] Thanks Jon. I think FILE HANDLE can be part of the solution. But I need FILE HANDLE to have a different value each time I run the syntax, according to the name of the current sav file. Is there a system variable with the file name? No dia 13/07/2013 02:07, "Jon K Peck" <peck@...>
escreveu:
Hello I have a syntax which I use in different sav files. In the end of the code, I want to save the sav file with its original name but in a diferent location. I think I can change the file path with the command CD. But I do not know how to use the current file's name in OUTFILE. Thanks. Ricardo ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 |
I have this code, but it saves the data file with the name #FileScratch instead of the string stored in #FileScratch. I don't have Python. Is it possible to solve the problem without it?STRING #FileScratch (A7). DO IF $CASENUM=1. COMPUTE #FileScratch=CONCAT(LTRIM(CodigoEscola),'.sav'). * CodigoEscola is the variable in the dataset containing part of the sav file name. It has the same value for all cases in each sav file. END IF. EXECUTE. FILE HANDLE FileName / NAME = #FileScratch. CD 'C:\Dropbox\Research\Ongoing\Entrepreneurship\EDEN\UNIDO\DataAnalysis\ProcessedData'. SAVE OUTFILE = FileName /KEEP= ID ALL. Ricardo Gouveia Rodrigues
Universidade da Beira Interior Covilhã Portugal 2013/7/13 Jon K Peck <[hidden email]> How are you opening the sav file? That would be the place to define the file handle. |
Free forum by Nabble | Edit this page |