Hello all,
After some time using STATA in different projects and always finding my own ways to get exactly what I want to achieve with my knowledge, I decided to ask whether there actually are better and easier ways to do it.
Example 1:
Variable "preschool" has already been created the only way I came up with, which is:
When the variables grder3* take value 0, it means that child attended preschool. So preschool should be 1 whenever a child has attended preschool at any year between 1994-2009 (grder394-grder309).
The idea of creating var lists or macros with grder3* is not what I am looking for since I will only use that group of variables once.
I would like to know if anyone knows an easier way to create the preschool variable.
Thanks in advance.
Francisco
After some time using STATA in different projects and always finding my own ways to get exactly what I want to achieve with my knowledge, I decided to ask whether there actually are better and easier ways to do it.
Example 1:
Code:
clear input str8 childid byte(grder309 grder308 grder307 grder306 grder305 grder304 grder303 grder302 grder301 grder300 grder399 grder398 grder397 grder396 grder395 grder394) float preschool "IN011048" . . . . . . . . . . . . . . . . 1 "IN011048" . . . . . . . . . . . . . . . . 1 "IN011048" 11 10 9 8 7 6 5 4 3 2 1 0 0 88 88 88 1 "IN011048" . . . . . . . . . . . . . . . . 1 "IN011049" . . . . . . . . . . . . . . . . 0 "IN011049" . . . . . . . . . . . . . . . . 0 "IN011049" 10 9 8 7 6 5 4 3 2 1 88 88 88 88 88 88 0 "IN011049" . . . . . . . . . . . . . . . . 0 "IN011050" . . . . . . . . . . . . . . . . 0 "IN011050" . . . . . . . . . . . . . . . . 0 "IN011050" 10 9 8 7 6 5 4 3 2 1 88 88 88 88 88 88 0 "IN011050" . . . . . . . . . . . . . . . . 0 end
Variable "preschool" has already been created the only way I came up with, which is:
Code:
gen preschool=0 replace preschool=1 if grder309==0 | grder308==0 | grder307==0 | grder306==0 | grder305==0 | grder304==0 | grder303==0 | grder302==0 | grder301==0 | grder300==0 | grder399==0 | grder398==0 | grder397==0 | grder396==0 | grder395==0 | grder394==0
The idea of creating var lists or macros with grder3* is not what I am looking for since I will only use that group of variables once.
I would like to know if anyone knows an easier way to create the preschool variable.
Thanks in advance.
Francisco
Comment