Hi there -
I am trying to append two dataset of consequent years from 1998 to 2019. I need a total of 21 files (1998-1999, 1999-2000, 2000-2001, 2001-2002, . . ., 2018-2019). Current names are 'sic1998', 'sic1999' 'sic2000', and so on 'sic2019'.
As the dataset is huge, I would like to use the command below, but I wonder if I can use `i+1' for the next year file.
This is for one year example:
use "G:\sic1998.dta" , clear
append using "G:\sic1999.dta"
save "G:\m1999.dta"
This is something what I want to do:
forvalues i = 1998(1)2019 {
use "G:\sic`i'.dta" , clear
append using "G:\sic`i+1'.dta"
save "G:\m`i+1'.dta"
}
I am trying to append two dataset of consequent years from 1998 to 2019. I need a total of 21 files (1998-1999, 1999-2000, 2000-2001, 2001-2002, . . ., 2018-2019). Current names are 'sic1998', 'sic1999' 'sic2000', and so on 'sic2019'.
As the dataset is huge, I would like to use the command below, but I wonder if I can use `i+1' for the next year file.
This is for one year example:
use "G:\sic1998.dta" , clear
append using "G:\sic1999.dta"
save "G:\m1999.dta"
This is something what I want to do:
forvalues i = 1998(1)2019 {
use "G:\sic`i'.dta" , clear
append using "G:\sic`i+1'.dta"
save "G:\m`i+1'.dta"
}
Comment