My Excel file "ws_dscd" has three sheets : "UK-US", "CN-JP", and "Others". The first row of each sheet contains variable names. How can I append all the sheets ?
-
Login or Register
- Log in with
clear* tempfile building save ` building', emptyok foreach s in UK-US CN-JP Others { import excel using ws_dscd.xlsx, firstrow sheet("`s'") clear append using `building' save `"`building'"', replace } use `building', clear
. clear* . tempfile building . save ` building', emptyok invalid file specification r(198);
clear* tempfile building save `building', emptyok import excel using ws_dscd.xlsx, describe local n_sheets `r(N_worksheet)' forvalues i = 1/`n_sheets' { local sheetname_`i' `r(worksheet_`i')' } forvalues i = 1/`n_sheets' { import excel using ws_dscd.xlsx, clear firstrow sheet(`"`sheetname_`i''"') append using `building' save `"`buildilng'"', replace } use `building', clear
xls2dta , clear allsheets importopts(cellrange(A2)) : append using append_excel_2nd_row.xlsx
. list +----------------------+ | A B C D | |----------------------| 1. | A B C D | 2. | 12 21 132 13 | 3. | 23 23 23 254 | 4. | A B C D | 5. | 53 59 533 55 | |----------------------| 6. | 66 623 623 66 | +----------------------+
Comment