|
|
|
||||
|
|
|||||
Let's begin by opening the data file.
File Open select File: c:\statistica\hs0.sta Open
Reordering variables in the data file is helpful both for organizational reasons as well as to minimize the amount of scrolling you need to do in order to see the variables that you are working with.
Data
Vars...
Move...
select gender as the from variable:
select gender as the to variable:
select id as the insert after: variable
OK
Adding variable labels is a very useful data management strategy, and we strongly encourage you to take the time to do this when you input a data set or receive a data file.
Data All variable specs... for schtyp, type in the label "The type of school the student attended.". OK
Now let's add some value labels.
double-click on gender click on "text labels" under "text label", type female and under "numeric", type 1 under "text label", type male and under "numeric", type 0 OK
If we look back at the variable specifications, we can see that the variable prgtype is a string variable, and this may cause some difficulty when we are using this variable in analyses. So let's create a numeric of this variable.
Vars... Copy... select prgtype OK
double-click on the new variable and rename it prog.
highlight prog
Data
Recode
for "category 1" type prog = "academic" and for "New Value 1" type 1
for "category 2" type prog = "general" and for "New Value 1" type 2
for "category 3" type prog = "vocati" and for "New Value 1" type 3
OK
Add a variable label to the variable that we just created.
Renaming variables is easy.
double-click on the variable gender and change the name to female
Add a variable label and value labels to female.
Suppose that we would like to recode some values of a variable. For example, we might want to change the 5s to missing for the variable race. First, we will make a copy of the variable and then change the values in the copied variable.
highlight race Insert Copy variables OK
double-click on the old race variable and rename it race_old.
highlight race
Data
Recode
for Category 1, type race = 5 and for New Value 1, click on "MD code"
OK
There are many ways that you can create a new variable. One way is to use a numeric expression. For example, let's create a variable called total that will be the sum of the reading, writing and math scores.
Insert Add variables... for "Name:" type total, and type =read+write+math in "long name" box at the bottom OK
Now let's summarize the variable that we have just created.
Statistics
Basic Statistics/Tables
Descriptive statistics
OK
Variables
select total
OK
Summary
We will recode total to become grade as shown below.
Vars... Copy... OK
double-click on the variable to change the name to grade
Data
Recode
for "Category 1", type grade <= 80 and for "New value 1", type D
for "Category 2", type grade <= 110 and for "New value 2", type C
for "Category 3", type grade <= 140 and for "New value 3", type B
for "Category 4", type grade <= 220 and for "New value 4", type A
OK
recoding total into grade:
0 - 80 = 1
80 - 110 = 2
110 - 140 = 3
140 - 220 = 4
Finally, let's make z-scores of some of our variables.
Vars... Copy... select read OK
double-click on the copy of read and rename it to zread.
Data
Standardize
Variables
select zread
OK
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services