Use the + character to add a variable to another variable:
- x = "Python is " y = "awesome" z = x + y. print(z)
- Merge variable a with variable b into variable c : a = "Hello" b = "World" c = a + b.
- To add a space between them, add a " " : a = "Hello" b = "World"
- x = 5. y = 10. print(x + y)
- x = 5. y = "John" print(x + y)
To create a two-way table in SPSS:
- Import the data set.
- From the menu bar select Analyze > Descriptive Statistics > Crosstabs.
- Click on variable Smoke Cigarettes and enter this in the Rows box.
- Click on variable Gender and enter this in the Columns box.
- Click the tab labeled Cells and select column under Percentages.
Using the Compute Variables Dialog Window
- Click Transform > Compute Variable.
- In the Target Variable area, type a name for the new variable that will be computed; let's call the new variable any_yes.
- In the Numeric Expression box, enter the expression.
- Click OK to complete the computation.
Merge two files in SPSS
- Use the SORT CASE command to sort each file you wish to merge on the index variable.
- After sorting, use the SAVE OUTPUT command to save each file to a systems file.
- Use the MATCH FILES command to merge the files and create a single, final version of the file.
2.6.1.3.SPSS: Frequency table of multiple variables with same values
- Click in the menubar on Analyze.
- Click on Tables (or in version 23 on Custom Tables)
- Click on Custom Tables.
- Select all the variables that you want to show and have the same values.
- Move them all to the Rows.
Click Data > Split File. Select the option Organize output by groups. Double-click the variable Gender to move it to the Groups Based on field. When you are finished, click OK.
Recoding data into two categories
- Enter the data in the SPSS Statistics Data Editor and name the variable "Ratings".
- Click on Transform > Recode Into Different Variable in the top menu.
- Transfer the variable you want to recode by selected it and pressing the button, and give the new variable a name and label.
Running the Procedure
- Open Compare Means (Analyze > Compare Means > Means).
- Double-click on variable MileMinDur to move it to the Dependent List area.
- Click Options to open the Means: Options window, where you can select what statistics you want to see.
- Click OK.
A grouping variable (also called a coding variable, group variable or by variable) sorts data within data files into categories or groups. It tells a computer system how you've sorted data into groups. Categorical variables: a category like “Male” or “Female” and “Control Group” or “Experimental Group.”
Example: Nominal categorical variables that have been coded numerically (e.g., recording a subject's gender as 1 if male or 2 if female) should be treated as numeric variables with zero decimal places. In this situation, the Measure setting must be defined as Nominal.
The categories (or groups) of the independent variable will define which samples will be compared in the t test. The grouping variable must have at least two categories (groups); it may have more than two categories but a t test can only compare two groups, so you will need to specify which two groups to compare.
Running the Procedure
- Click Transform > Recode into Different Variables.
- Double-click on variable CommuteTime to move it to the Input Variable -> Output Variable box. In the Output Variable area, give the new variable the name CommuteLength, then click Change.
- Click the Old and New Values button.
- Click OK.
Multiple response sets are constructed from multiple variables in the data file. A multiple response set is a special construct within a data file. You can define and save multiple response sets in IBM® SPSS® Statistics data files, but you cannot import or export multiple response sets from/to other file formats.
The Variable View tab displays information about the variables in your data. You can get to the Variable View window in two ways: In the Data Editor window, click the Variable View tab at the bottom. In the Data Editor window, in the Data View tab, double-click a variable name at the top of the column.
Age can be both nominal and ordinal data depending on the question types. I.e "How old are you" is a used to collect nominal data while "Are you the first born or What position are you in your family" is used to collect ordinal data. Age becomes ordinal data when there's some sort of order to it.
Multiple responses. Analyze > Multiple Response deals with questions where several answers were possible, answers stored in as many variables as there are possible answers to the question.