Hello, I'm quite new to Stata and need help with some code. The idea is that I would like to create a panel data set from an excel workbook that contains numerous sheets (161 sheets). These sheets each contain company data from the Nigerian stock exchange and has identical headings of 19 variables (Date, Price, Market cap...e.t.c). I wish to, therefore, create a panel data set in Stata that combines all these companies.

I have code that creates 161 data files, the problem comes when I wish to append all these data files into one, Stata gives the following error "variable Price is double in master but str17 in using data. You could specify append's force option to ignore this numeric/string mismatch. The using variable would then be treated as if it contained numeric missing value."

I tried force appending but that was not a good idea, I, therefore, request help in modifying my code to convert the variables to numeric before appending.

The excel file is quite large so here is a google drive link in case testing is required. https://drive.google.com/file/d/1JVY...ew?usp=sharing

Your help would be greatly appreciated.

Please find my code below:

clear all
set more off
set excelxlsxlargefile on
*================================================= ========
*import all stocks data from each sheet using a loop
*================================================= ========
forvalues i=1/161 { //put the last number of the last sheet. here there were 3 only
import excel using project_data.xls, firstrow sheet(`i') clear //import each sheet in turn
tempfile john`i' //create a temporary file to save imported from each sheet
save john`i', replace //save the temporary file
}

use "john1" , clear //create a temporary master file from temporary file above
set more off

forvalues i=2/161 { //replace 3 with the highest number in your sheet
append using "john`i'"
}