Assignment No. 5 - Data Transformations Please read the document "Data Transformations.doc" (attached


Assignment No. 5 – Data Transformations

Please read the document "Data Transformations.doc" (attached below) to learn about COMPUTE, IF, and RECODE statements.

Please write 4 statements of each kind to perform data transformations. They may relate to one variable, or more, as you choose.

Run at least one analysis that demonstrated the changes that you made. Examples would be to run FREQUENCIES before and after the transformation (so that the difference is clear) or T-TEST on groups that were created as a result of the transformations that you performed.

If you are working on a full-featured version of SPSS (for example, on a University computer or with the Graduate Pack), please save the syntax file and submit it along with your assignment. If you are working with the Student Version of SPSS, you do not have access to write syntax outside of the menus. Please write the syntax that you would have used (and which was created by the menus) along with the demonstrating analyses.

As referred to above:

Data Transformations

This document will detail three types of data transformations that are commonly used in SPSS. The concept behind them is found in most programming languages and statistical packages, so understanding it in SPSS will help you if you need to re-create the same thing in other situations. The three are related, so understanding one will help you understand the others.

Please note: SPSS does not perform transformations as soon as it reads that they are requested. In the "olden days" when computers ran much slower (or even today on exceptionally large files), reading the data and applying transformations was time-consuming and therefore expensive. In order to save that, SPSS would read the transformations and store them in memory. They are actually performed on the data when a process is requested, such as an analysis. Another way to get them to be run is to click on the "Run Pending Transforms" option of the "Transform" menu, or to issue the following syntax command:

EXECUTE.

COMPUTE

COMPUTE statements allow you to create values for new variables or to change values of existing variables. (Please note: if the new variable is a string variable (contains characters other than numbers, it must be predefined by using the STRING command.)

The format of the statement is:

COMPUTE newvar = value.

where NEWVAR is the name of the new variable, and VALUE is the value that you are assigning to that variable. VALUE can be the name of another, existing variable if you want to create a new variable that will be equal to another one (in case you want to then transform that new variable without affecting the original). It can also be a formula that includes another variable that you are changing in some way.

For example:

compute curryear=2007.

compute diameter=radius*2.

compute hsgradyr=birthyr+18.

IF

IF statements are conditional compute statements. That is, you are telling SPSS to perform the compute IF the condition holds true. If the condition does not hold true, the transformation will not be performed and the variable in question will remain unchanged. The VALUE part of the statement can also be a formula, as with the COMPUTE command.

Some formula abbreviations are necessary in order to issue the commands, including:

EQ (equals)

LT (less than)

GT (greater than)

LE (less than or equal to)

GE (greater than or equal to).

Using the keywords AND and OR allow you to make combinations of conditions.

The format of the statement is:

IF condition variable=value.

Examples:

if birthyr lt 1950 agegroup=1.

if birthyr ge 1951 agegroup=2.

if sex eq 1 and educ le 12 category=1.

if sex eq 1 and educ gt 12 category=2.

if sex eq 2 and educ le 12 category=3.

if sex eq 2 and educ gt 12 category=4.

RECODE

RECODE is a kind of compute statement that takes the values in a variable and rearranges them. You can either use the original variable and just change the values or you can create a copy of the variable and change the values in that new variable so that you also retain the original. The latter is done by adding the word INTO at the end of the command, followed by the name of the new variable. (Of course, you could create a copy of the variable using a COMPUTE statement, followed by a RECODE of the copy variable). One of the common uses of this command is to reverse the order of questions in a questionnaire when some of the questions go from good-to-bad and some go from bad-to-good in order to prevent automatic responses on the part of respondents.

The format of the statement is:

RECODE variable (old value or values=new value or values) (old value or values=new value or values) (old value or values=new value or values) .

For example:

recode grade (1,2,3,4=1)(5,6,7,8=2)(9,10,11,12=3).

recode satisfied (1=7)(2=6)(3=5)(5=3)(6=2)(7=1).

Note: in the second example, I didn’t add any recoding for the value 4, because would have been (4=4) and therefore, not undergoing any change.

Price: $14.28
Solution: The downloadable solution consists of 9 pages, 528 words and 5 charts.
Deliverable: Word Document


log in to your account

Don't have a membership account?
REGISTER

reset password

Back to
log in

sign up

Back to
log in