Hi,
I am using a loop to collect summary statistics using the matrix function. For example, the columns are districtid districtname (string variable) and minimum_score. districtid is an arbitrary numerical id for each district.
forval dst=1/3 {
summarize score if districtid==`dst'
local min_score = r(min)
matrix stats[`dst',1] = `dst'
matrix stats[`dst',2] = ????????????????
matrix stats[`dst',3] = `min_score'
display districtname if districtid==`dst'
}
I have no problem collecting the min_score statistics, but I have problems displaying the district name in the matrix. I can't define a local containing the district name using the display or tabulate function. Any ideas how I can get the matrix to store the districtname? I would prefer to display the districtname rather than the districtid because districtid is arbitrary to the dataset.
Thank you.
Best,
Yi
I am using a loop to collect summary statistics using the matrix function. For example, the columns are districtid districtname (string variable) and minimum_score. districtid is an arbitrary numerical id for each district.
forval dst=1/3 {
summarize score if districtid==`dst'
local min_score = r(min)
matrix stats[`dst',1] = `dst'
matrix stats[`dst',2] = ????????????????
matrix stats[`dst',3] = `min_score'
display districtname if districtid==`dst'
}
I have no problem collecting the min_score statistics, but I have problems displaying the district name in the matrix. I can't define a local containing the district name using the display or tabulate function. Any ideas how I can get the matrix to store the districtname? I would prefer to display the districtname rather than the districtid because districtid is arbitrary to the dataset.
Thank you.
Best,
Yi
Comment