Dear all,

I an trying to perform a PCA analysis by company on panel data.

The goal is to create an index out of multiple variables for each company which should use the same variable name (aware_pca_test) for all companies.

Currently my code looks like this

Code:
levelsof gvkey, local(gvkeys)
foreach i of local gvkeys{
pca Awareness_score womexposure_score if gvkey == `" `i'"'
rotate
predict aware_pca_test if gvkey == `" `i'"'
}
I receive the error "type mismatch" when performing this code. What could be the reason?

Any advice would be most appreciated.

Thanks and best,
Micha