|
Good morning,
I am importing data from Excel and have a variable that is importing as numeric, but I need to be a string. I selected the column in Excel and changed the format of the cells to 'text' and thought that would do the trick, but it didn't. How can I do this in SPSS? I did some Googling and found this, but it didn't work: COMPUTE notcontinuing=STRING(notcontinuing,N8). EXECUTE. The name of the variable is: notcontinuing. I'm an SPSS novice, so the simpler the solution, the better. Thanks! Andrew |
|
What happens if you change numeric to string in the type column in the Data Editor? Click on Numeric, then on blue box, then on String button at bottom of list. John F Hall (Mr) [retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com -----Original Message----- Good morning, I am importing data from Excel and have a variable that is importing as numeric, but I need to be a string. I selected the column in Excel and changed the format of the cells to 'text' and thought that would do the trick, but it didn't. How can I do this in SPSS? I did some Googling and found this, but it didn't work: COMPUTE notcontinuing=STRING(notcontinuing,N8). EXECUTE. The name of the variable is: notcontinuing. I'm an SPSS novice, so the simpler the solution, the better. Thanks! Andrew -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Numeric-to-String-tp5717551.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 |
|
Ah yes, I can do that, but because I have to run this syntax twice per week for the next 16 weeks, I would prefer not to have to do it manually like that every time. If there's a way I can do it "automated' with syntax, that would be my preference.
|
|
In reply to this post by John F Hall
Andrew Replies should be posted to the list: that way they are shared and in this case you will get what you want (when everyone has finished watching the inauguration). John From: Andrew McCloskey [mailto:[hidden email]] Ah yes, I can do that, but because I have to run this syntax twice per week for the next 16 weeks, I would prefer not to have to do it manually like that every time. If there's a way I can do it "automated' with syntax, that would be my preference. On Mon, Jan 21, 2013 at 10:51 AM, John F Hall <[hidden email]> wrote: What happens if you change numeric to string in the type column in the Data Editor? Click on Numeric, then on blue box, then on String button at bottom of list. John F Hall (Mr) [retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com -----Original Message----- Good morning, I am importing data from Excel and have a variable that is importing as numeric, but I need to be a string. I selected the column in Excel and changed the format of the cells to 'text' and thought that would do the trick, but it didn't. How can I do this in SPSS? I did some Googling and found this, but it didn't work: COMPUTE notcontinuing=STRING(notcontinuing,N8). EXECUTE. The name of the variable is: notcontinuing. I'm an SPSS novice, so the simpler the solution, the better. Thanks! Andrew -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Numeric-to-String-tp5717551.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 |
|
In reply to this post by AndrewM
Don't you need to create the String variable first?:
string Newvar (A8). compute newvar = string(notcontinuing, f8.0). exe. ===================== 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 AndrewM
You need to either declare a different
variable as a string and then do the compute or, more easily, use
ALTER TYPE to change the type of the existing variable. p.s. It isn't helpful to just say something didn't work. Describe what actually happened, including any error message. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: AndrewM <[hidden email]> To: [hidden email], Date: 01/21/2013 10:28 AM Subject: [SPSSX-L] Numeric to String Sent by: "SPSSX(r) Discussion" <[hidden email]> Good morning, I am importing data from Excel and have a variable that is importing as numeric, but I need to be a string. I selected the column in Excel and changed the format of the cells to 'text' and thought that would do the trick, but it didn't. How can I do this in SPSS? I did some Googling and found this, but it didn't work: COMPUTE notcontinuing=STRING(notcontinuing,N8). EXECUTE. The name of the variable is: notcontinuing. I'm an SPSS novice, so the simpler the solution, the better. Thanks! Andrew -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Numeric-to-String-tp5717551.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 |
|
Administrator
|
In reply to this post by AndrewM
As others have mentioned:
You need to pre-declare the string variable. See ALTER TYPE. "Didn't work?" Please elaborate: Please read my post "Tips on Posting the the SPSS List". Post what the variable looks like in the beginning. Post whatever error messages/warnings! Hard to see why anything REALLY needs to be a string variable UNLESS:. If for example you have non numeric characters using a compute post import will not salvage these instances. You need to CYA in Excel prior to import. If not, the a string variable really has no advantages over a numeric. --
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?" |
|
If you think you need it to be a string
because you just want to display leading zeroes, use the N format, as in:
formats varname (N5). This will display a value of 1234 as 01234, a value of 1 as 00001, etc. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: David Marso <[hidden email]> To: [hidden email], Date: 01/21/2013 12:45 PM Subject: Re: Numeric to String Sent by: "SPSSX(r) Discussion" <[hidden email]> As others have mentioned: You need to pre-declare the string variable. See ALTER TYPE. "Didn't work?" Please elaborate: Please read my post "Tips on Posting the the SPSS List". Post what the variable looks like in the beginning. Post whatever error messages/warnings! Hard to see why anything REALLY needs to be a string variable UNLESS:. If for example you have non numeric characters using a compute post import will not salvage these instances. You need to CYA in Excel prior to import. If not, the a string variable really has no advantages over a numeric. -- AndrewM wrote > Good morning, > > I am importing data from Excel and have a variable that is importing as > numeric, but I need to be a string. I selected the column in Excel and > changed the format of the cells to 'text' and thought that would do the > trick, but it didn't. > > How can I do this in SPSS? I did some Googling and found this, but it > didn't work: > > COMPUTE notcontinuing=STRING(notcontinuing,N8). > EXECUTE. > > The name of the variable is: notcontinuing. > > I'm an SPSS novice, so the simpler the solution, the better. Thanks! > > Andrew ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Numeric-to-String-tp5717551p5717557.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 |
| Free forum by Nabble | Edit this page |
