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 generate a new variable?

To create a new variable in SPSS, use the compute command. You can use this command in many ways. Following are some examples:

  • If you want to create a variable called total equal to the sum of variables v1, v2, v3, and v4, the syntax is: compute total = v1+v2+v3+v4.
  • You can use most basic mathematical expressions to combine variables into new variables with compute statements. Alternatively, you can also use SPSS functions with compute commands. For example, the following command also adds the values of v1, v2, v3, and v4 to create a variable called total: compute total = sum(v1 to v4).

    Note: The difference between the two procedures above is that in the first procedure, the case on total would be missing if any one of the four variables had missing values on a case; in the second procedure, the total would be computed ignoring missing values on the four variables.

  • You can use the compute command to create a copy of an existing variable to be modified or recoded while preserving the original values of the variable. For example, if you wish to create a copy of the variable v1 called v1a, type: compute v1a = v1.
  • You can also use the compute command to create a constant variable. For example, if you wish to create a constant variable called v5 and the value for the constant is 1, type: compute v5 = 1.

For more information on the compute command, refer to the SPSS Command Syntax Reference (in PDF format).

For more information about statistical and mathematical software, email the UITS Stat/Math Center, visit the center's web page, or phone 812-855-4724 (IUB) or 317-278-4740 (IUPUI). The center is located in Bloomington at 410 N. Park Avenue, and is open for consultation by appointment Monday-Friday 9am-5pm.

This is document afsh in domain all.
Last modified on November 18, 2008.

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.