I can’t seem to find a way of manipulating a file path. Perhaps it’s just not possible. I have the following:
GET DATA /TYPE=XLSX /FILE='I:\PLANNING\POLICY\STATS\2016\CIT\BBStats\BP160211.xlsx' /SHEET=name 'BP' /CELLRANGE=full /READNAMES=on /ASSUMEDSTRWIDTH=32767. EXECUTE. which was predefined for me in the list file when I did File > Open > Data and then selected a spreadsheet I wanted to open. I just copied and pasted the code. Now that I’ve got the code I wanted to add something like the following: String p1 (A8). Compute p1 = ‘BP160211’. and change the path in the above to /FILE='I:\PLANNING\POLICY\STATS\2016\CIT\BBStats\p1.xlsx' SPSS didn't like it. (File doesn't exist or is being used.) So, I tried to set it up as a macro (with my new found knowledge) by making p1 a parameter (I remembered my ! when I did so), but still no go. |
Administrator
|
The FILE HANDLE command may be what you want.
http://www-01.ibm.com/support/knowledgecenter/SSLVMB_23.0.0/spss/base/syn_file_handle_examples.dita Alternatively, you could indeed use macros. The following is untested, but should give you the idea. (I'm using forward slashes to make the code closer to usable on Macs. Macs demand forward slashes; Windows, on the other hand, is very forgiving on this issue, and automatically converts them to backward slashes.) DEFINE !Path () "I:/PLANNING/POLICY/STATS/2016/CIT/BBStats/" !ENDDEFINE. DEFINE !p1 () "BP160211" !ENDDEFINE. DEFINE !ext () ".xlsx" ENDDEFINE. GET DATA /TYPE=XLSX /FILE= !Path + !p1 + !ext /SHEET=name 'BP' /CELLRANGE=full /READNAMES=on /ASSUMEDSTRWIDTH=32767. Another option would be to enclose the GET DATA command in a macro, and pass the path, file name and extension to it as arguments. If you provide a bit of context, it might be clearer what the best solution is for you. HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Using literal concatenation as Bruce has done will work, because the + here causes the literals on both sides of it to be joined so that they function as if they had been typed together, but to clarify why the OP approach did not, note that the COMPUTE command is creating a casewise variable (p1) while the syntax would need a single value that can be evaluated by the syntax parser without any reference to the data. On Mon, Feb 15, 2016 at 6:58 PM, Bruce Weaver <[hidden email]> wrote: The FILE HANDLE command may be what you want. |
Administrator
|
In reply to this post by Ron0z
What Jon and Bruce said...
"So, I tried to set it up as a macro (with my new found knowledge) by making p1 a parameter (I remembered my ! when I did so), but still no go. " Any particular reason why you neglected to post your MACRO attempt? Maybe there is a blatant/obvious reason for the "no go". ---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |