Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

In SPSS, how do I convert between numeric variables and string variables?

In SPSS, to convert a numeric variable to a string variable, use the STRING() function. Since the default variable type in SPSS is numeric, you need to define your string variable in advance. Consider the following example:

STRING str (A8). COMPUTE str = STRING(num, F2.0). EXECUTE.

In the example above, A8 indicates a string variable eight characters long, and F2.0 is the format of output values of variable num. For example, F8.4 fills four zeroes after the decimal point when the numeric variable num is an integer.

To convert a string variable to a numeric variable num, use the NUMBER() function, for example:

COMPUTE num = NUMBER(str, F8.2). EXECUTE.
This is document aoym in domain all.
Last modified on December 20, 2011.

Comments/Questions/Corrections

Use this form to offer suggestions, corrections, and additions to the Knowledge Base. We welcome your input!

If you are affiliated with Indiana University and would like assistance with a specific computing problem, please use the Ask a Consultant form, or contact your campus Support Center.

Contact Information

Note: We will reply to your comment at this address. If your message concerns a problem receiving email, please enter an alternate email address.