Hi Everyone,
Please I'm new with regards to the use of Stata and I really need your assistance.
I have imported an excel data in Stata which contains 16 variables (2 string variables and 14 numeric variables) with some missing values (specifically "n.a." type of missing values) and all efforts to delete the "n.a." or replace them with recognized stata missing values such as "." or "" have all proved futile. I really don't know if there is a way to delete them or replace all the "n.a." with missing values.
In an attempt to replace them with missing values, I tried the following codes but it didn't work, I got a feedback which reads "type mismatch" :
foreach var of varlist * {
replace `var'="" if `var'=="NA"
}
foreach var of varlist * {
replace `var'="" if `var'=="n.a."
}
Moreover, in an attempt to delete all the observations with "n.a.", I tried the following codes but it also didn't work, I got the same feedback which reads "type mismatch" :
foreach var of varlist Interest_Revenue-Equity {
drop if `var'=="NA"
}
foreach var of varlist Interest_Revenue-Equity {
drop if `var'=="n.a."
}
Please is there a way to delete all the "n.a." or replace all the "n.a." with missing values??? Thanks in advance!!
Please I'm new with regards to the use of Stata and I really need your assistance.
I have imported an excel data in Stata which contains 16 variables (2 string variables and 14 numeric variables) with some missing values (specifically "n.a." type of missing values) and all efforts to delete the "n.a." or replace them with recognized stata missing values such as "." or "" have all proved futile. I really don't know if there is a way to delete them or replace all the "n.a." with missing values.
In an attempt to replace them with missing values, I tried the following codes but it didn't work, I got a feedback which reads "type mismatch" :
foreach var of varlist * {
replace `var'="" if `var'=="NA"
}
foreach var of varlist * {
replace `var'="" if `var'=="n.a."
}
Moreover, in an attempt to delete all the observations with "n.a.", I tried the following codes but it also didn't work, I got the same feedback which reads "type mismatch" :
foreach var of varlist Interest_Revenue-Equity {
drop if `var'=="NA"
}
foreach var of varlist Interest_Revenue-Equity {
drop if `var'=="n.a."
}
Please is there a way to delete all the "n.a." or replace all the "n.a." with missing values??? Thanks in advance!!
Comment