Hello SPSS listserve:
I'm trying to combine (i.e., append or stack) two datasets with the same variables. I'm receiving an error about a conflicting variable type, but all the variables are strings. Does the different lengths of the variables cause the error? Any suggestions are appreciated. ADD FILES /FILE="C:\Users\Desktop\Files \SPSS\1 Prototype.sav" /FILE='C:\Users\Desktop\Files \SPSS\2 Prototype.sav' /IN=afile. VARIABLE LABELS afile 'Case source is C:\Users\mdemichele\Desktop\Files from BJS\SPSS\ABD Prototype.sav'. Variable(s) with conflicting type: -------Input1------- -------Input2------- _STATE_CODE_1 s116 _STATE_CODE_1 s8 _STATE_CODE_1 _STATE_CODE_2 s50 _STATE_CODE_2 s8 _STATE_CODE_2 _STATE_CODE_3 s43 _STATE_CODE_3 s8 _STATE_CODE_3 _FIRST_NAME s23 _FIRST_NAME s11 _FIRST_NAME _LAST_NAME s40 _LAST_NAME s20 _LAST_NAME >Error # 5127 >Mismatched variable types on the input files. >Execution of this command stops. Thank you, Matthew ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Matthew
Variables must match in type and in the case of strings - length. Just adjust the shorter ones to the length of the longer and all will work OK Best Wishes John S. Lemon Student Liaison Officer IT Services - University of Aberdeen t: +44 (0) 1224 273350 | m: +44 (0) 7710 491780 | e:[hidden email] | www.abdn.ac.uk/it/ Use MyIT to log calls with IT Services, and to update and check the status of your calls - https://myit.abdn.ac.uk -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of DeMichele, Matthew Sent: 21 March 2014 14:06 To: [hidden email] Subject: adding files command Hello SPSS listserve: I'm trying to combine (i.e., append or stack) two datasets with the same variables. I'm receiving an error about a conflicting variable type, but all the variables are strings. Does the different lengths of the variables cause the error? Any suggestions are appreciated. ADD FILES /FILE="C:\Users\Desktop\Files \SPSS\1 Prototype.sav" /FILE='C:\Users\Desktop\Files \SPSS\2 Prototype.sav' /IN=afile. VARIABLE LABELS afile 'Case source is C:\Users\mdemichele\Desktop\Files from BJS\SPSS\ABD Prototype.sav'. Variable(s) with conflicting type: -------Input1------- -------Input2------- _STATE_CODE_1 s116 _STATE_CODE_1 s8 _STATE_CODE_1 _STATE_CODE_2 s50 _STATE_CODE_2 s8 _STATE_CODE_2 _STATE_CODE_3 s43 _STATE_CODE_3 s8 _STATE_CODE_3 _FIRST_NAME s23 _FIRST_NAME s11 _FIRST_NAME _LAST_NAME s40 _LAST_NAME s20 _LAST_NAME >Error # 5127 >Mismatched variable types on the input files. >Execution of this command stops. Thank you, Matthew ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD The University of Aberdeen is a charity registered in Scotland, No SC013683. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
In reply to this post by DeMichele, Matthew
"Does the different lengths of the variables cause the error?"
YES! This has been a PITA for some 20+ years despite frequent user complaints. "Any suggestions are appreciated." Open each file, scrutinize lengths. Use ALTER TYPE command to fix up files. Then use ADD FILES with dataset names rather than disk/path filenames. eg. GET FILE datafilefromdisk..... ALTER TYPE varlist (format). DATASET NAME somename1. ..... repeat. ADD FILES / FILE somename1 / FILE somename?
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?" |
I've struggled with this, also.
Does anybody have a nice solution when dealing with a couple of dozen files, with a lot of string variables? I'm at the point of having to load the variable names, types and lengths into an excel spreadsheet, and using some functions to find the longest length for each string. Barry <quote author="David Marso"> "Does the different lengths of the variables cause the error?" YES! This has been a PITA for some 20+ years despite frequent user complaints. "Any suggestions are appreciated." Open each file, scrutinize lengths. Use ALTER TYPE command to fix up files. Then use ADD FILES with dataset names rather than disk/path filenames. eg. GET FILE datafilefromdisk..... ALTER TYPE varlist (format). DATASET NAME somename1. ..... repeat. ADD FILES / FILE somename1 / FILE somename?" |
The STATS ADJUST WIDTHS will take a wildcard
set of files and adjust strings widths for the variables according to a
rule you specify such as maximum width.
It also gives you a table of conflicts showing variables that are numeric in some files and strings in others. It is Data > Adjust Widths Across Files in the menus or syntax like this. STATS ADJUST WIDTHS VARIABLES=ALL WIDTH=MAX MAXWIDTH=500 DSNAMEROOT=adjust_ /FILES "c:\mydata\*.sav" /OUTFILE RESAVE=YES DIRECTORY="c:\mydata\adjusted" OVERWRITE=NO SUFFIX="_adj" CLOSE=NO. This requires the Python Essentials, which is included with Statistics or available with your Statistics download or from the SPSS Community website (www.ibm.com/developerworks/spssdevcentral) depending on your version. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Barry <[hidden email]> To: [hidden email], Date: 06/25/2014 10:13 AM Subject: Re: [SPSSX-L] adding files command Sent by: "SPSSX(r) Discussion" <[hidden email]> I've struggled with this, also. Does anybody have a nice solution when dealing with a couple of dozen files, with a lot of string variables? I'm at the point of having to load the variable names, types and lengths into an excel spreadsheet, and using some functions to find the longest length for each string. Barry "Does the different lengths of the variables cause the error?" YES! This has been a PITA for some 20+ years despite frequent user complaints. "Any suggestions are appreciated." Open each file, scrutinize lengths. Use ALTER TYPE command to fix up files. Then use ADD FILES with dataset names rather than disk/path filenames. eg. GET FILE datafilefromdisk..... ALTER TYPE varlist (format). DATASET NAME somename1. ..... repeat. ADD FILES / FILE somename1 / FILE somename?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/adding-files-command-tp5724965p5726583.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
That's handy. I thought about making a command "FORCE APPEND' that does this. Does it also append strings and numerical variables with a common name? The numerical variable should be stringified,of course, or else you might end op with lots of sysmis values. Regards, Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
The command does not change the type between
numeric and string, since the user needs to decide which is correct. A
typical mixed-type situation is an import from Excel where the fields are
supposed to be all numeric, but because of stray characters, some come
in as string. ALTER TYPE, of course, can fix this once the correct
type is determined. The command automatically ignores numeric variables
except to check the string/numeric mismatch.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Albert-Jan Roskam <[hidden email]> To: Jon K Peck/Chicago/IBM@IBMUS, "[hidden email]" <[hidden email]>, Date: 06/25/2014 12:42 PM Subject: Re: [SPSSX-L] adding files command That's handy. I thought about making a command "FORCE APPEND' that does this. Does it also append strings and numerical variables with a common name? The numerical variable should be stringified,of course, or else you might end op with lots of sysmis values. Regards, Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From: Jon K Peck <[hidden email]> To: [hidden email] Sent: Wednesday, June 25, 2014 6:37 PM Subject: Re: [SPSSX-L] adding files command The STATS ADJUST WIDTHS will take a wildcard set of files and adjust strings widths for the variables according to a rule you specify such as maximum width. It also gives you a table of conflicts showing variables that are numeric in some files and strings in others. It is Data > Adjust Widths Across Files in the menus or syntax like this. STATS ADJUST WIDTHS VARIABLES=ALL WIDTH=MAX MAXWIDTH=500 DSNAMEROOT=adjust_ /FILES "c:\mydata\*.sav" /OUTFILE RESAVE=YES DIRECTORY="c:\mydata\adjusted" OVERWRITE=NO SUFFIX="_adj" CLOSE=NO. This requires the Python Essentials, which is included with Statistics or available with your Statistics download or from the SPSS Community website (www.ibm.com/developerworks/spssdevcentral) depending on your version. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Barry <[hidden email]> To: [hidden email], Date: 06/25/2014 10:13 AM Subject: Re: [SPSSX-L] adding files command Sent by: "SPSSX(r) Discussion" <[hidden email]> I've struggled with this, also. Does anybody have a nice solution when dealing with a couple of dozen files, with a lot of string variables? I'm at the point of having to load the variable names, types and lengths into an excel spreadsheet, and using some functions to find the longest length for each string. Barry "Does the different lengths of the variables cause the error?" YES! This has been a PITA for some 20+ years despite frequent user complaints. "Any suggestions are appreciated." Open each file, scrutinize lengths. Use ALTER TYPE command to fix up files. Then use ADD FILES with dataset names rather than disk/path filenames. eg. GET FILE datafilefromdisk..... ALTER TYPE varlist (format). DATASET NAME somename1. ..... repeat. ADD FILES / FILE somename1 / FILE somename?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/adding-files-command-tp5724965p5726583.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
________________________________
> From: Jon K Peck <[hidden email]> >To: [hidden email] >Sent: Wednesday, June 25, 2014 8:57 PM >Subject: Re: [SPSSX-L] adding files command > > > >The command does not change the type between >numeric and string, since the user needs to decide which is correct. A >typical mixed-type situation is an import from Excel where the fields >are supposed to be all numeric, but because of stray characters, some >come in as string. ALTER TYPE, of course, can fix this once the >correct type is determined. The command automatically ignores numeric >variables except to check the string/numeric mismatch. Yes, I've had exactly this before. Sheets where '-' means 'missing', 'x' means 'suppressed', 'n/a' means 'impossible', etc. And then there are messay sheets with just some forgotten dot or whatever somewhere. With R it's even worse, esp. if you don't use stringsAsFactors=FALSE! Bottom line is that Excel needs to go. :-) regards, Albert-Jan ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Jon K Peck
Jon, I've tried to run this, but it's not a recognized command. I'm wondering if I have the Python Essentials installed (I'm on version 22). How do I check?
Thanks, Barry "The STATS ADJUST WIDTHS will take a wildcard set of files and adjust strings widths for the variables according to a rule you specify such as maximum width. It also gives you a table of conflicts showing variables that are numeric in some files and strings in others. It is Data > Adjust Widths Across Files in the menus or syntax like this. STATS ADJUST WIDTHS VARIABLES=ALL WIDTH=MAX MAXWIDTH=500 DSNAMEROOT=adjust_ /FILES "c:\mydata\*.sav" /OUTFILE RESAVE=YES DIRECTORY="c:\mydata\adjusted" OVERWRITE=NO SUFFIX="_adj" CLOSE=NO. This requires the Python Essentials, which is included with Statistics or available with your Statistics download or from the SPSS Community website (www.ibm.com/developerworks/spssdevcentral) depending on your version. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 " |
You need to restart Statistics after installing
the command. In V22 you can check the installation via Utilities
> Extension Bundles > Download and Install Extension bundles or View
Installed Extension Bundles. That first item will tell you whether
you have the Python Essentials installed via the Prerequisites column.
Starting with V22, the Python Essentials are automatically installed
with Statistics unless you specifically choose not to when you install
Statistics.
If you installed the command after the initial Statistics install, you might need to start Statistics using Run As Administrator in order for Statistics to have sufficient permission to install the necessary files. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Barry <[hidden email]> To: [hidden email], Date: 06/26/2014 08:24 AM Subject: Re: [SPSSX-L] adding files command Sent by: "SPSSX(r) Discussion" <[hidden email]> Jon, I've tried to run this, but it's not a recognized command. I'm wondering if I have the Python Essentials installed (I'm on version 22). How do I check? Thanks, Barry "The STATS ADJUST WIDTHS will take a wildcard set of files and adjust strings widths for the variables according to a rule you specify such as maximum width. It also gives you a table of conflicts showing variables that are numeric in some files and strings in others. It is Data > Adjust Widths Across Files in the menus or syntax like this. STATS ADJUST WIDTHS VARIABLES=ALL WIDTH=MAX MAXWIDTH=500 DSNAMEROOT=adjust_ /FILES "c:\mydata\*.sav" /OUTFILE RESAVE=YES DIRECTORY="c:\mydata\adjusted" OVERWRITE=NO SUFFIX="_adj" CLOSE=NO. This requires the Python Essentials, which is included with Statistics or available with your Statistics download or from the SPSS Community website (www.ibm.com/developerworks/spssdevcentral) depending on your version. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 " -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/adding-files-command-tp5724965p5726592.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Jon, I'm sorry to reply offline, but I can't find your latest post on the SSPSX-L list (that's a frustrating place). I also apologize to readers of SPSSX-L if this comes at the end of the old messages; I'm still using Yahoo!, which does stuff like that/ How can I get the Python extension installed on SPSS 22? Note that if I reinstall SPSS from the disc, I'll need to contact my university licensing office for another license code, and I can't afford to break SPSS and not work for a day or two or three. Thanks! Barry On Thursday, June 26, 2014 10:38 AM, Jon K Peck [via SPSSX Discussion]
<[hidden email]> wrote:
|
In reply to this post by Jon K Peck
"You need to restart Statistics after installing the command. In V22 you
can check the installation via Utilities > Extension Bundles > Download and Install Extension bundles or View Installed Extension Bundles. That first item will tell you whether you have the Python Essentials installed via the Prerequisites column. Starting with V22, the Python Essentials are automatically installed with Statistics unless you specifically choose not to when you install Statistics. If you installed the command after the initial Statistics install, you might need to start Statistics using Run As Administrator in order for Statistics to have sufficient permission to install the necessary files." Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 That worked beautifully! |
Free forum by Nabble | Edit this page |