Reputation: 1097
year
0
1
6
....
(omit)
....
77
90
....
(omit)
....
The "year" is a numeric variable. I need to add "200" before the 1-digit values, and "19" before the 2-digit values.
year
2000
2001
2006
....
1977
1990
....
How can I do this in Stata?
Upvotes: 2
Views: 1381
Reputation: 37358
Be careful: the variable might be byte
and that will bite.
This should work:
gen year2 = cond(year < 10, 2000 + year, 1900 + year)
tab year2
If year2
looks good,
drop year
rename year2 year
Upvotes: 2