In my data, I have a numeric number called year which have value from 2 to 22, I want to replace this variable by a variable year1 which have the value from 2001 to 2021.
For sure the very clear way to do is:

Code:
gen year1=.
replace year1=2001 if (year==2)
replace year1=2002 if (year==3)
.replace year1=2003 if (year==4)
.
.
.
(similar code)
However, it is around 21 lines of code and it is not necessarily like that from my point of view. I have a look at some ways to shorten it. For example, by using the semicolon delimiter as mentioned in this archive.
My code is

Code:
replace year1=2001 if (year==2); replace year1=2002 if (year==3)
However, it turns out the error like that
Code:
unknown function ()
r(133);
Could you please help me to sort it out?Thanks in advance