I need to export and save SPSS output into Excel format for more than 100 people. I am trying to avoid renaming the files manually. Like in Python, I tried to add the full-name variable into the file path, but I get this error every time:

The procedure cannot access a file with the given file specification: C:\PROGRA~1\IBM\SPSSST~1\full_name_concat.xlsx. The file specification is either syntactically invalid, specifies an invalid drive or directory, specifies a protected directory, specifies a protected file, or specifies a non-sharable file.

This is the part of the syntax that I tried to achieve it:


STRING full_name_concat (A255).
COMPUTE full_name_concat = CONCAT (' "C:\Users\itenis\Documents\ARPS\FOR CREATING PROFILES\OUTPUT ', RTRIM(full_name), '.xlsx" ').
  
OUTPUT EXPORT
  /CONTENTS EXPORT=VISIBLE LAYERS=VISIBLE MODELVIEWS=VISIBLE
   /XLSX DOCUMENTFILE='full_name_concat'
     OPERATION=CREATEFILE
     LOCATION=STARTCELL('a1')  NOTESCAPTIONS=NO.

I spent hours searching for answers before I decided to take the risk and ask here.

I'd appreciate your help.

1

There are 1 best solutions below

0
eli-k On

OK this won't work because the syntax will not interpret the column name and use the values in it's operations. There are two ways to make this happen - one is through SPSS macro (this is a nice site to look it up). The other way is through write command - the following code writes a new syntax that creates a new command for each value of full_name:

STRING full_name_concat (A255).
COMPUTE full_name_concat = CONCAT (' "C:\Users\itenis\Documents\ARPS\FOR CREATING PROFILES\OUTPUT ', RTRIM(full_name), '.xlsx" ').

write out="your path\do named outputs.sps" 
       /"OUTPUT EXPORT"
       /"/CONTENTS EXPORT=VISIBLE LAYERS=VISIBLE MODELVIEWS=VISIBLE"
       /"/XLSX DOCUMENTFILE=", full_name_concat
       /"OPERATION=CREATEFILE"
       /"LOCATION=STARTCELL('a1')  NOTESCAPTIONS=NO." .

exe.
insert file="your path\do named outputs.sps".