Good afternoon to the community.
I would like to calculate the mean and standard deviation of intangible assets per industry.

Array

But when, i run the command of my do-file editor, i get the error "variable industry_n not found" , error in option by())
I share my Stata file "File2.dta" in attachment.



Code:
cd "C:\Users\lucas\Documents\GP\"

use"File2.dta", clear

preserve
*mean and standard deviation of intangible_assets per year
collapse (mean) mean_intangible_assets=intangible_assets (sd) sd_intangible_assets=intangible_assets, by(year)
asdoc list, replace
*encode string variable industry (video: https://www.youtube.com/watch?v=ZRWHjdIZyxo)
*mean and standard deviation of intangible_assets per industry
collapse (mean) mean_intangible_assets=intangible_assets (sd) sd_intangible_assets=intangible_assets, by(industry_n)
asdoc list, replace
restore

*Export dataset
save "File2.dta", replace

export excel using "File2.xlsx", sheetreplace firstrow(variables)
Thank you for your help.