![]() We then change the values of the gender variable from 1,2 to 0,1. Below we use rename to rename gender to female, which is what female=1 indicates. Consider giving dummy (indicator) variables the name signified by the value of 1. The variable gender may give us trouble in the future because it isĭifficult to know what the 1s and 2s mean. We use encode to create a numeric version of this variable, called prog, which will use the string values of prgtype as the value labels. Labels can be suppressed in many commands using the nolabel option.ĭ) The encode command will convert a string variable to numeric and will label its values automaticallyīecause the variable prgtype is a string variable, it cannot be used in any commands requiring numerical calculations. Labels will typically be used in the output. We then apply the “scl” label to the schtyp variable.Ĭodebook schtyp /*check for value labels first */ Below we create a set of value labels called “scl”, which gives meaning to the values 1 and 2. Categorical variables should thus use numbers to define the categories and value labels to give meaning to the numbers. Variable labels allow us to provide a longer description of the variable’s contents.Ĭ) Use label define to create a set of value labels, and then use label values to apply the value labels to a variableĪll variables that undergo any kind of numerical calculation must have a numerical represenation in Stata. Short variables are desirable to keep coding clean, but may obscure what the variable reprsents. To remember the contents of a dataset, we can apply a label to it as well as some notes, using the note command. The last columns will then contain the test scores.ī) Use label data to describe the dataset and label variable to give variable names more meaning. ![]() Variables describing the students, such as gender, race, sesĪnd prgtype in the first few columns. While there are several possible orderings of variables thatĪre logical, we will put the id variable first, followed by the demographic We first load the data and use codebook to look at all variables, including labeling information.Ī) Use order to control the ordering of variables as columns in the dataset In this section we will use Stata commands to label and transform variables, and to create new variables that are functions of existing variables. Define value labels for a categorical variableĬreate numeric version of a string variableĮxtended generate – has special functions that can
0 Comments
Leave a Reply. |