OUTPUT EXPORT - Use variable to specify filename

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Ellebjerg
Posts: 9
Joined: Thu Aug 04, 2011 9:11 am
Location: Copenhagen

OUTPUT EXPORT - Use variable to specify filename

Postby Ellebjerg » Tue Jan 21, 2014 9:58 am

I am trying to simplify a syntax, which in future will be used by others.

In the syntax I use OUTPUT EXPORT to create an Excel file and after this to add new sheets with data. I do this with the following syntax:

begin program.
import time, spss
spss.SetMacroValue("!timestamp", "'" + time.strftime("%Y-%m-%d") + "'")
end program.

OUTPUT EXPORT
/CONTENTS EXPORT=VISIBLE
/XLSX DOCUMENTFILE ='U:/Data/Øget sundhed for børn/Københavnerbarometer/KB-Sund_2011-2013 ' + !timestamp + '.xlsx'
OPERATION=CREATEFILE
SHEET='Livskvalitet'
LOCATION=STARTCELL('A1').

OUTPUT EXPORT
/CONTENTS EXPORT=VISIBLE
/XLSX DOCUMENTFILE ='U:/Data/Øget sundhed for børn/Københavnerbarometer/KB-Sund_2011-2013 ' + !timestamp + '.xlsx'
OPERATION=CREATESHEET
SHEET='Skoletilfredshed'
LOCATION=STARTCELL('A1').

This all works very nicely, but in order to make it simpler for other users to save output to a different location I want to specify the path and filename once in a variable in the beginning of the syntax and then use this variable in the rest of the syntax.
I can make this work by specifying the filename in the python code, except that it does not work when path or filename contains the Danish letter Ø, and presumably not with Æ and Å either. I cannot make it work by specifying the path and filename in a SPSS string variable in the syntax. How can this be done?

Regards
Lars

Who is online

Users browsing this forum: No registered users and 1 guest

cron