SPSSINC Process Files translate SAV files into xls files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SPSSINC Process Files translate SAV files into xls files

SUBSCRIBE SPSSX-JohnF
Any help would be appreciated....I have the following code\syntax.....which runs, however the supposed excel files can't be read by excel....indicates wrong format or the file is corrupted.  Looked at it using "Notepad" and it is gobbly-gook, although I
saw the word "workbook" in the mess of gobbly-gook.  Thanks for any assistance......

SPSSINC PROCESS FILES INPUTDATA="C:\state_files\*.SAV"
  SYNTAX="C:/state_files//TransFiles2.sps"
  OUTPUTDATADIR="C:/temp/testONE/Completed/"
  VIEWERFILE= "C:/temp/testONE/OUTPUT.SPV"
  LOGFILE="C:/temp/testONE/log.txt" MACRONAME="!JOB" LOGFILEMODE=APPEND
/MACRODEFS ITEMS.

Here is the translate code\syntax....TransFiles2.sps

GET FILE = "job_inputfile".
SAVE TRANSLATE OUTFILE=!Out
  /TYPE=XLS
  /VERSION=12
  /MAP
  /REPLACE
  /FIELDNAMES
  /CELLS=LABELS
  /KEEP=state fipscode.
exe.
define !out () !quote(!concat(!unquote(!eval(!job_outputdatadir)), "/",
!unquote(!eval(!job_datafileroot)), ".xls"))
!enddefine.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: SPSSINC Process Files translate SAV files into xls files

Jon Peck
Excel files are binary, so they should look like "gobbly_gook" in a text editor.

Two suggestions:  try running one file manually to see what it produces.

Is it possible that the output file names being produced are different from the ones you expected?  Run SET MPRINT ON before this code so you can see better what is being generated.

On Thu, Sep 14, 2017 at 10:31 AM, SUBSCRIBE SPSSX-JohnF <[hidden email]> wrote:
Any help would be appreciated....I have the following code\syntax.....which runs, however the supposed excel files can't be read by excel....indicates wrong format or the file is corrupted.  Looked at it using "Notepad" and it is gobbly-gook, although I
saw the word "workbook" in the mess of gobbly-gook.  Thanks for any assistance......

SPSSINC PROCESS FILES INPUTDATA="C:\state_files\*.SAV"
  SYNTAX="C:/state_files//TransFiles2.sps"
  OUTPUTDATADIR="C:/temp/testONE/Completed/"
  VIEWERFILE= "C:/temp/testONE/OUTPUT.SPV"
  LOGFILE="C:/temp/testONE/log.txt" MACRONAME="!JOB" LOGFILEMODE=APPEND
/MACRODEFS ITEMS.

Here is the translate code\syntax....TransFiles2.sps

GET FILE = "job_inputfile".
SAVE TRANSLATE OUTFILE=!Out
  /TYPE=XLS
  /VERSION=12
  /MAP
  /REPLACE
  /FIELDNAMES
  /CELLS=LABELS
  /KEEP=state fipscode.
exe.
define !out () !quote(!concat(!unquote(!eval(!job_outputdatadir)), "/",
!unquote(!eval(!job_datafileroot)), ".xls"))
!enddefine.

=====================
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



--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSSINC Process Files translate SAV files into xls files

SUBSCRIBE SPSSX-JohnF
In reply to this post by SUBSCRIBE SPSSX-JohnF
Thank you....problem solved the definition for macro !OUT was misplaced......

GET FILE = "job_inputfile".
define !out () !quote(!concat(!unquote(!eval(!job_outputdatadir)), "/",
!unquote(!eval(!job_datafileroot)), ".xlsx"))
!enddefine.
SAVE TRANSLATE OUTFILE=!Out
  /TYPE=XLS
  /VERSION=12
  /MAP
  /REPLACE
  /FIELDNAMES
  /CELLS=LABELS
  /KEEP=state fipscode recnumbr date_of_discharge discharge_reason.
exe.

=====================
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