|
Hello Group,
I have a field with 3 different numeric variables which I want to separate out into 3 different fields. I'm using the CHAR.SUBSTR to try and partition the variables out. But it's not working because that's a STRING function not a NUMERIC function. I don't want to loose any of the zero's at the beginning of the variable, is there no way around that if I'm trying to separate it out to 3 different fields? Would the Restructure command in SPSS work out better in my case. Sample Data: 0429708 0345989 0098747 I need these variables separated out in 3 different fields. Thanks in advance, MK ===================== 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 |
|
Pleas tell us more about what you are trying to do?
Where is this field? Is this data that is already in a package? A numeric field would not have embedded blanks in most display formats. Is it character data in fixed columns? .txt? .asc? etc? Is it already in SPSS? If it is, are you sure it is numeric? Art Kendall Social Research Consultants subscribe SPSSX-l Anonymous wrote: > Hello Group, > > I have a field with 3 different numeric variables which I want to separate > out into 3 different fields. I'm using the CHAR.SUBSTR to try and partition > the variables out. But it's not working because that's a STRING function > not a NUMERIC function. I don't want to loose any of the zero's at the > beginning of the variable, is there no way around that if I'm trying to > separate it out to 3 different fields? Would the Restructure command in > SPSS work out better in my case. > > Sample Data: > > 0429708 0345989 0098747 > > I need these variables separated out in 3 different fields. > > Thanks in advance, > > MK > > ===================== > 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
Art Kendall
Social Research Consultants |
|
Something like this untested syntax should do it.
*as a string. string instructor1 to instructor3 (a7). compute instructor1 = substr(mystring, 1,7). compute instructor2 = substr(mystring, 9,7). compute instructor3 = substr(mystring,17,7). * or as a number with leading zeros. numeric n_instructor1 to n_instructor2 (n7). compute n_instructor1 = number(substr(mystring, 1,7),n7). compute n_instructor2 = number(substr(mystring, 9,7),n7). compute n_instructor3 = number(substr(mystring,17,7),n7). Art Kendall Social Research Consultants Michelle Kors wrote: Hello Art,
Art Kendall
Social Research Consultants |
| Free forum by Nabble | Edit this page |
