Changing Your Data
Stata can be used to manipulate data for a variety of uses. Using Stata, you can:- Create new variables.
- Recode existing variables.
- Create dummy variables for analysis.
This is a common task for educators. You have scores for two or more tests for any number of students and want to calculate an average score for each student. The example below uses test scores for a class of 50 students to create two new variables; average and grades.
Creating a New Variable- From the Stata menu, select Data.
- From the sub-menu, select Create or change variable.
- From the next menu, select Create new variable.
- Provide a name to the new variable such as "Average" and type the desired expression in the box underneath Contents of new variable:(expression) .In the example below, the expression (test1 +test2)/2 gives the average of the two scores.
- Use the scroll bar to select a New variable type. In the example below, int has been selected for integer data, to give each student a whole number score. Other common types are float to allow decimals or string for character data, such as names.
Last updated:
December 01, 2008