Spss create new variable from multiple variables

15.07.2020   |   by Gumi

Many easy options have been proposed for combining the values of categorical variables in SPSS. However, the real information is usually in the value labels instead of the values. This tutorial proposes a simple trick for combining categorical variables and automatically applying correct value labels to the result.

You may follow along by downloading and opening hospital. The result is shown in the screenshot below. Note that all variables are numeric with proper value labels applied to them.

We first present the syntax that does the trick. Next, we'll point out how it how to easily use it on other data files. We realize that many readers may find this syntax too difficult to rewrite for their own data files. So instead of rewriting it, just copy and paste it and make three basic adjustments before running it:.

You may have noticed that the value labels of the combined variable don't look very nice if system missing values are present in the original values. A nicer result can be obtained without changing the basic syntax for combining categorical variables. Use a value that's not yet present in the original variables and apply a value label to it. The syntax below shows how to do so. Further, note that the syntax we used made a couple of assumptions.

Most real world data will satisy those. We'll walk through them below. SPSS Combine Categorical Variables - Assumptions Although the syntax combines two variablesit can be expanded to incorporate three or more variables.

It is assumed that all values in the original variables consist of single digits. If two or three digit values are present, replace f1 by n2 or n3.You can use the Chart Builder to create charts that summarize and compare multiple variables.

For example, if sales data for each year are recorded in a separate variable, you can create a single chart that summarizes sales data for each year in a separate bar. Note : Not all chart types support summaries of separate variables as described in this topic. You cannot create summaries of separate variables for histograms, population pyramids, boxplots, and dual axis charts.

High-low-close charts summarize separate variables, but these charts have separate zones for each variable. See the topic High-Low Charts for more information. Note : If the gallery chart contains a point element, the previous action will create an overlay scatterplot. See the topic Scatterplots and dot plots for more information. To create summaries of separate variables for a point element, you must first drag a categorical variable to the x axis. When you summarize multiple variables, the Chart Builder creates a new variable whose categories are the individual variables.

The y axis displays the summarized value for each variable. It acts like a categorical variable. Because the summary group variable acts like a categorical variable, you delete a variable from the summary group in the same way that you delete a category from a categorical axis or grouping zone. You can also right-click the drop zone in which the summary group variable appears and choose Delete Variable from the pop-up menu.

Summarizing separate variables You can use the Chart Builder to create charts that summarize and compare multiple variables.

How to create a chart that summarizes multiple variables Note : Not all chart types support summaries of separate variables as described in this topic.

Drag a gallery chart or a graphic element onto the canvas. Drag one of the scale variables that you want to summarize to the y axis. Drag another scale variable to the top section of the y -axis drop zone. The Create Summary Group dialog box then appears. Click OK to create the summary group variable. If necessary, drag additional variables to the y -axis drop zone.A multiple-response set is much like a new variable made of other variables you already have.

But it does show up among the items you can choose from when defining graphs and tables. The following steps explain how you can define a multiple-response set, but not how you can use one — that comes later when you generate a table or a graph. Also, there are two Multiple Response menus: The one in the Data menu is for tables and graphs; the one in the Analyze menu is for using special menus that you see in this example.

Generate a new variable in SPSS

Note four dichotomous variables that have 1 for Yes and 0 for No as their possible answers, as shown here. Your variables appear in the Set Definition area. If you previously defined any multiple datasets, they appear in the list on the right.

spss create new variable from multiple variables

In the Set Definition list, select each variable you want to include in your new multiple dataset, and then click the arrow to move the selections to the Variables in Set list. The dollar sign in the filename identifies the variable as a multiple-response set. The new name will appear in two special menus in the Analyze menu.

There are other applications of multiple response as well, notably in the menus of the Custom Tables module, but you have to define those multiple-response sets in the Data menu.

The new special Frequencies report appears in the output window, as shown here.

Creating a New or Combined Variable Using SPSS

Ten people bought 24 pieces of fruit. Nine pieces of fruit were apples — So, the difference is the denominator. What makes this table special is that what you usually care about is the people with multiple responses. In other words, how many people shopping at the store are going to buy apples along with other things that they might buy?

This table is the only one that easily displays them both ways. If multiple-response sets are a common variable type for you, you should consider trying to get the Custom Tables module because it offers lots of options for this kind of variable.

spss create new variable from multiple variables

The window showing the complete definition. The Multiple Response Frequencies dialog box. The Multiple Response Frequencies table.This module shows how to create and recode variables.

In SPSS you can create new variables with compute and you can modify the values of an existing variable with recode. In this section we will see how to create new variables with compute. The variable length contains the length of the car in inches. Below we see summary statistics for length. Let's use the compute command to make a new variable that has the length in feet instead of inches, called lenft.

Or we might want to make loglen which is the natural log of length. Note that you can shorten the command descriptive to just descand you can shorten variables to var. Let's get the mean and standard deviation of length and we can make Z-scores of length. In SPSS there are two ways to get the z-scores, and we will show you both ways. The first way is to use the save subcommand after the descriptive command.

This will save the z-scores into the data file. The other way to obtain z-scores is to make them manually, and the code necessary to do that is shown below.

When making z-scores manually, you do not need to use the save subcommand with the descriptive command. The mean is Suppose that we wanted to break mpg down into three categories. Let's look at a table of mpg to see where we might draw the lines for such categories. Let's convert mpg into three categories to help make this more readable. Here we convert mpg into three categories using compute and if. Now, we could use mpg3 to show a crosstab of mpg3 by foreign to contrast the mileage of the foreign and domestic cars.

Case Processing Summary Cases. Valid Missing Total. MPG3 1. Total Count 52 22 There is an easier way to recode mpg to three categories using recode. Using this method, we do not need to make a copy of mpg or use the compute command. We simply use the recode command with the into option with the name of the new variable into which we want to recode mpg. In this case, we will recode mpg into mpg3a using three categories: lo into 1, into 2, and hi into 3.

Subscribe to RSS

Let's create a variable called mpgfd that assesses the mileage of the cars with respect to their origin.Merging some categories of a categorical variable in SPSS is not hard if you do it the right way.

This tutorial demonstrates just that. Right, when doing a routine inspection of this data file, we'll see that the variable nation has many small categories. Before doing so, however, we'll first apply a variable label to this variable.

The frequency table tells us that we have respondents from Belgium and from England but only 2 from France and 1 from Germany. Based on the entire frequency table, we choose to reorganize these nationalities as follows:. Reorganizing nationalities like so requires merging all countries with small frequencies together into a new category. We'll now show two solid approaches for doing just that. Keep in mind that this new variable doesn't come with any variable labels or value labels.

We'll therefore apply these ourselves. Note that every table row contains only zeroes except for one cell. Since this pattern holds for all rows, we conclude that the result is indeed correct. The first option we proposed uses only very basic syntax so it will work fine on all SPSS versions. A disadvantage, as we saw, is that it requires applying variable and value labels to the new variable. We'll therefore propose a faster approach that circumvents this.

After doing so, we can use the syntax below for merging our categories as desired. Finally, we inspect the result in the same way as we did previously.

How To Compute A Mean Variable In SPSS

Note that the values of the adjusted variable are not contiguous. That is, we're using 1, 2, 11, However, for reporting purposes we usually display only value labels and not the underlying values. However, since these don't show up in any way, this does not bother us either. Apply variable label to nation. Show values and value labels in following output tables. Run basic frequency table.

Create new nationality variable. Apply value labels to new variable. Apply variable label to new variable. Show variable names and labels in succeeding output. Inspect whether result is correct. Clone variable requires SPSS clone variables tool in order to run. Recode original variable.This page will talk you through the basics of altering your variables, computing new ones, transforming existing ones and will introduce you to syntax : a computer language that can make the whole process much quicker.

We briefly introduced the Variable View on Page 1. Correctly setting up your variables is the key to performing good analysis — your house falls down if you do not put it on a good foundation! Each variable in your dataset is entered on a row in the Variable View and each column represents a certain setting or property that you can adjust for each variable in the corresponding cell.

There are 10 settings:. This inevitably results in variable names that make no sense to anyone but the researcher! Type: This is almost always set to numeric. You can specify that the data is entered as words string or in dates if you have a specific purpose in mind Remember that even categorical variables are coded numerically. This allows you to restrict the number of digits that can be typed into a cell for that variable e.

Decimals: Similar to Widththis allows you to reduce the number of decimal places that are displayed. This can make certain variables easier to interpret. Nobody likes values like 0. Label: This is just a typed description of the variable, but it is actually very important! The Name section is very restrictive but here you can give a detailed and accurate sentence about your variable.

spss create new variable from multiple variables

It is very easy to forget what exactly a variable represents or how it was calculated and in such situations good labelling is crucial! Values: This is another important one as it allows you to code your ordinal and nominal variables numerically.

spss create new variable from multiple variables

Clicking on the cell for the relevant variable will summon a pop-up menu like the one shown below. This menu allows you to assign a value to each category level of your variable. Simply type the value and label you want in the relevant boxes at the top of the menu and then click Add to place them in the main window.

You can also Change or Remove the value labels you have already placed in the box. When you are satisfied with the list of value labels you have created click OK to finalise them. You can edit this at any time. Missing: This setting can also be very important as it allows you to tell SPSS how to identify cases where a value is missing. This might sound silly at first — surely SPSS can assign a value as missing when a value is well Actually there are lots of different types of missing value to consider and sometimes you will want to include missing cases within your analysis Extension B talks about missing data in more detail.

Clicking on the cell for the relevant variable will summon the pop-up menu shown below. You can type in up to three individual values or a range of values which you wish to be coded as missing and treated as such during analysis. By allowing for multiple missing values you can make distinctions between types of missing data e. You can give these values labels in the normal way using the Values setting.Search everywhere only in this topic.

Advanced Search. Classic List Threaded. Deepa Bhat. Recoding multiple variables into one new variable. Hi everyone, I have a database in which the data entry staff entered the responses to one question in four different columns.

I would like to combine it all into one column. I don't have to worry about any response overriding another one because each response is affiliated with a different person. I am trying to avoid doing frequencies of each and tallying it up the total by hand. Is there a syntax that will allow me to recode multiple variables into one variable? ViAnn Beadle. Re: Recoding multiple variables into one new variable.

Search for multiple response in the HELP system. Hashmi, Syed S. In reply to this post by Deepa Bhat. Deepa, I don't know if this is the best method, but you can do that by using a different RECODE command for each of the original variables tested in v.

A couple of points to remember: 1. This will only work if you don't have rows with data in more than one column. If you do, then the latter variable will overwrite the previous one. I don't have to worry about any response overriding another. Samir Omerovic. Of course both methods assume there is only one value in each row so it is not actual multiple answer.

In reply to this post by Hashmi, Syed S. This definitely will not work.


Recent Comments