GRETL - How do I create a dummy variable with a column that contains the salary of an individual, being 1 when the salary exists and 0 when salary is empty using the missing command in GRETL
GRETL - missing command to create dummy variables in GRETL
363 views Asked by Albert Aedo Pereira At
2
There are 2 answers
0
On
This is a shorter way of doing what you need, and it will be much faster when working with large data as no looping is involved:
nulldata 3
series salary = {800, 500, NA}
series salary_dummy = NA
# if salary is _not_missing_ return '1', else '0'
series salary_dummy = (ok(salary)) ? 1 : 0
print salary salary_dummy -o
This returns:
salary salary_dummy
1 800 1
2 500 1
3 0
You can use the "ok" function: