Hello everyone,
I need help with changing a variable from numeric to string. Thanks for a lot for your assistance greatly. Jody. |
At 08:11 PM 2/11/2007, Jody weru wrote:
>I need help with changing a variable from numeric to string. Well (smile) there's a function for this, named: STRING. Notice, if it matters to you that this does not convert a numeric *variable* to a string variable; it accepts a numeric value, and calculates a string value. And you use a numeric format in the STRING function, to select what string representation you will get. Like this; SPSS 15 draft output. (Code and listing not saved separately.) NEW FILE. DATA LIST FREE /NUMBER1. BEGIN DATA 1 2 3.3 4.25 5 END DATA. STRING CONVERT1 CONVERT2 CONVERT3 (A8). COMPUTE CONVERT1 = STRING(NUMBER1, F3). COMPUTE CONVERT2 = STRING(NUMBER1, F5.2). COMPUTE CONVERT3 = STRING(NUMBER1, E8.1). LIST. List |-----------------------------|---------------------------| |Output Created |11-FEB-2007 23:34:43 | |-----------------------------|---------------------------| NUMBER1 CONVERT1 CONVERT2 CONVERT3 1.00 1 1.00 1.0E+000 2.00 2 2.00 2.0E+000 3.30 3 3.30 3.3E+000 4.25 4 4.25 4.3E+000 5.00 5 5.00 5.0E+000 Number of cases read: 5 Number of cases listed: 5 |
In reply to this post by Jody weru
Hi,
You can't change it. You can only create a new string-type variable string new (A8). compute new = string (old,A8). exe. Albert-Jan --- Jody weru <[hidden email]> wrote: > Hello everyone, > I need help with changing a variable from numeric to > string. > Thanks for a lot for your assistance greatly. > Jody. > Cheers! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ____________________________________________________________________________________ It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar. http://tools.search.yahoo.com/toolbar/features/mail/ |
In reply to this post by Jody weru
Hi Richard,
Thanks for sharing the syntax. It was very helpful. On 2/11/07, Jody weru <[hidden email]> wrote: > > Hello everyone, > I need help with changing a variable from numeric to string. > Thanks for a lot for your assistance greatly. > Jody. > |
In reply to this post by Albert-Jan Roskam
Hi
I had the same question as Jody and found the Syntax from Alber-Jan - but it doesn't work with me. It gives me an error message: There is no numeric argument which ist expected for this function (Attention: traduced from German!). The new string variable remains empty. Thanks for any hint. Tom -----Ursprüngliche Nachricht----- Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Albert-jan Roskam Gesendet: Montag, 12. Februar 2007 19:27 An: [hidden email] Betreff: Re: Syntax for converting numeric to string Hi, You can't change it. You can only create a new string-type variable string new (A8). compute new = string (old,A8). exe. Albert-Jan --- Jody weru <[hidden email]> wrote: > Hello everyone, > I need help with changing a variable from numeric to > string. > Thanks for a lot for your assistance greatly. > Jody. > Cheers! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ____________________________________________________________________________________ It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar. http://tools.search.yahoo.com/toolbar/features/mail/ |
At 04:04 AM 3/2/2007, Balmer Thomas wrote:
>I had the same question as Jody and found the Syntax from Alber-Jan - >but it doesn't work with me. The problem with >>compute new = string (old,A8). is the 'A8'. The two arguments to "string" are the number to be converted, and the *numerical* format according to which to convert it. Illustration below. (Regular readers: apologies for re-post) >There's a function for this, named: STRING. This does not convert a >numeric *variable* to a string variable; it accepts a numeric value, >and calculates a string value. And you use a numeric format in the >STRING function, to select what string representation you will get. >Like this; SPSS 15 draft output. (Code and listing not saved >separately.) > >NEW FILE. >DATA LIST FREE /NUMBER1. >BEGIN DATA >1 2 3.3 4.25 5 >END DATA. >STRING CONVERT1 CONVERT2 CONVERT3 (A8). >COMPUTE CONVERT1 = STRING(NUMBER1, F3). >COMPUTE CONVERT2 = STRING(NUMBER1, F5.2). >COMPUTE CONVERT3 = STRING(NUMBER1, E8.1). >LIST. > > >List >|-----------------------------|---------------------------| >|Output Created |11-FEB-2007 23:34:43 | >|-----------------------------|---------------------------| > NUMBER1 CONVERT1 CONVERT2 CONVERT3 > > 1.00 1 1.00 1.0E+000 > 2.00 2 2.00 2.0E+000 > 3.30 3 3.30 3.3E+000 > 4.25 4 4.25 4.3E+000 > 5.00 5 5.00 5.0E+000 > >Number of cases read: 5 Number of cases listed: 5 |
Free forum by Nabble | Edit this page |