|
Hi all,
I want to import data. The data has the same name but it is located in a folder (actual date). I want to import this data and save it as a Spss-file for further analysis. When I use a Macro like below SPSS looks only in "c:\Import\" for import "rawdata.txt". Do you have a hint where is my mistake? Thanks in advance for help. Alex DEFINE !import (folder=!ENCLOSE('(',')') /vnames=!CMDEND) !LET !Path_readout = !CONCAT( 'c:\Import\' ,!folder) . !LET !Path_raw = 'D:\Export\' . GET DATA /TYPE=TXT /FILE=!QUOTE(!CONCAT(!Path_readout,"rawdata.txt")) /DELCASE=LINE /DELIMITERS="\t" /ARRANGEMENT=DELIMITED /FIRSTCASE=2 /IMPORTCASE=ALL SAVE OUTFILE =!QUOTE(!CONCAT(!Path_raw,!vnames,".sav")). !ENDDEFINE. !import folder = (Data 2012-05-19\) vnames=XY_120519. |
|
Administrator
|
Alex,
Hard to say: It appears to be doing exactly what you are telling it to do. Use SET MPRINT ON. to see the macro expansion. You are also missing a command terminator on DEFINE() line -although it might not matter-. GET DATA complains about a missing VARIABLES subcommand. You are also missing the command terminator on GET DATA -again might not matter-. OTOH: Nix the blank line between GET DATA and SAVE and you've got a train wreck. Always best to thoroughly TEST your syntax prior to macrofication (tm). HTH, David --- DEFINE !import (folder=!ENCLOSE('(',')') /vnames=!CMDEND) !LET !Path_readout = !CONCAT( 'c:\Import\' ,!folder) . !LET !Path_raw = 'D:\Export\' . GET DATA /TYPE=TXT /FILE=!QUOTE(!CONCAT(!Path_readout,"rawdata.txt")) /DELCASE=LINE /DELIMITERS="\t" /ARRANGEMENT=DELIMITED /FIRSTCASE=2 /IMPORTCASE=ALL SAVE OUTFILE =!QUOTE(!CONCAT(!Path_raw,!vnames,".sav")). !ENDDEFINE. SET MPRINT ON. !import folder = (Data 2012-05-19\) vnames=XY_120519. 39 0 M> 40 0 M> . 41 0 M> 42 0 M> GET DATA /TYPE=TXT /FILE= 'c:\Import\Data 2012-05-19\rawdata.txt' /DELCASE=LINE /DELIMITERS='\t' /ARRANGEMENT=DELIMITED /FIRSTCASE=2 /IMPORTCASE=ALL. >Error. Command name: GET DATA >(2255) Missing subcommand: /VARIABLES >Execution of this command stops. 43 0 M> SAVE OUTFILE = 'D:\Export\XY_120519.sav' >Error # 105. Command name: SAVE >This command is not valid before a working file has been defined. >Execution of this command stops. 44 0 M> .
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 |
