Hi,
With following data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(disease_experience drought_experience flood_experience disease_prediction drought_prediction flood_prediction)
1 3 1 2 1 3
2 4 3 3 3 4
3 5 4 4 6 5
4 6 5 1 7 6
end
I executed
Code:
unab experience : *_experience
local experience: subinstr local experience "_experience" "", all

unab prediction : *prediction
local prediction : subinstr local prediction "_prediction" "", all

local prefixes : list experience & prediction

foreach s of local prefixes { 
pwcorr `s'_experience `s'_prediction, sig
}
Actually, I wanted a single matrix of all the coefficients and p values with *experience variables on row and *prediction variables on column. But, it produces as many matrices as the number of variables.

Would any tweaking in the code help me get what I wanted?