Stata: extract pvalues and save them in a list
By : Maria
Date : March 29 2020, 07:55 AM
may help you . Here is an approach that would save the pvalues in a matrix and then you can manipulate the matrix, maybe using Mata or standard matrix manipulation in Stata. code :
matrix storeMyP = J(2, 1, .) //create empty matrix with 2 (as many variables as we are looping over) rows, 1 column
matrix list storeMyP //look at the matrix
loc n = 0 //count the iterations
foreach variableName of varlist b c {
loc n = `n' + 1 //each iteration, adjust the count
reg a `variableName'
test `variableName' //this does an Ftest, but for one variable it's equivalent to a ttest (check: help test there is lots this can do
matrix storeMyP[`n', 1] = `r(p)' //save the pvalue in the matrix
}
matrix list storeMyP //look at your pvalues
matrix storeMyP_2 = 2*storeMyP //replicating your example above

extract value from variable stata
By : abullard
Date : March 29 2020, 07:55 AM

Extract Stata matrix element by column name
By : Ryan Dean
Date : March 29 2020, 07:55 AM
should help you out See help matrix subscripting for an explanation of why your attempt at subscripting using column names didn't work. Replacing your line with code :
scalar beta = b[1,colnumb(b,"`v'")]

Extract intercepts from multiple regressions in stata
By : Barak Sh
Date : March 29 2020, 07:55 AM

Extract value label in command [stata]
By : Daniel Pavic
Date : March 29 2020, 07:55 AM
it should still fix some issue I am trying to create a new string variable that combines the string of a real number (an ID) with a name. The name is a numeric variable with a value label. , The best I can do is two lines. code :
decode num, generate(label)
replace label = string(id) + "  " + label

