Hi everyone,
I'm trying to import a batch of 1000 csv files which are downloaded from a specific database. However, the database, for some reason includes additional empty columns at the end of the file which poses some problems in the following data treatment procedures (requires reshapping). Those files are imported without names in the variables meaning that stata assignes v1...vn names to the variables.
I know which columns should be deleted it the value of the 4th (and on, but only need the 4th one) is missing. Is there a way going through each 4th observation of each variable and delete that variables if it returns missing? I know the command should use the foreach loop, but I'm unable to delete the variable. I've tried the following without any luck
foreach v of varlist v*{
drop `v' if missing(`v'[4])
}
I'm trying to import a batch of 1000 csv files which are downloaded from a specific database. However, the database, for some reason includes additional empty columns at the end of the file which poses some problems in the following data treatment procedures (requires reshapping). Those files are imported without names in the variables meaning that stata assignes v1...vn names to the variables.
I know which columns should be deleted it the value of the 4th (and on, but only need the 4th one) is missing. Is there a way going through each 4th observation of each variable and delete that variables if it returns missing? I know the command should use the foreach loop, but I'm unable to delete the variable. I've tried the following without any luck
foreach v of varlist v*{
drop `v' if missing(`v'[4])
}
Comment