Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

OUTPUT EXPORT - Use variable to specify filename

270006Y8TY gravatar image
Question by Ellebjerg  (0) | Jan 21, 2014 at 11:04 AM spssstatisticssyntax
   I am trying to simplify a syntax, which in future will be used by others.<br>


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

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

3 answers

  • Sort: 
270002VCWN gravatar image

Answer by JonPeck (4671) | Feb 12, 2014 at 01:43 PM

For the file name, you don't need Python code. You can just do something like this and the o-slash and other extended characters will work.

define !filespec() 'c:/temp/ abc.pdf' !enddefine.

   OUTPUT EXPORT
 

     /CONTENTS  EXPORT=ALL  LAYERS=ALL  MODELVIEWS=ALL
 

     /PDF  DOCUMENTFILE=!filespec
 

...

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270006Y8TY gravatar image

Answer by Ellebjerg (0) | Feb 12, 2014 at 09:07 AM

I am not familiar with Python, just found this solution through google, so my python solution was simply to use the same code as for the timestamp, only specifying the entire path and filename. This worked nicely without the Danish letter but not with it. A possible work around could be to specify that the three Danish letters cannot be part of the path or filename, but as is in the project name, this would be awkward.

I am working in SPSS v. 22. I can see that I am running Unicode. This could explain the problem. I will try shifting to 'OS writing system'.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270002VCWN gravatar image

Answer by JonPeck (4671) | Jan 21, 2014 at 01:54 PM

How are you specifying the value in your Python code? What version of Statistics are you using? Are you running in Unicode mode or code page mode?

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

46 people are following this question.

Answers

Answers & comments

Related questions

Defining a date variable as missing 1 Answer

Copy & Paste Problem with SPSS 21.0 and the Syntax Editor 18 Answers

Removing value labels with a syntax 3 Answers

Matrix Help 4 Answers

Concatenating across rows of data 2 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges