Skip to content

Instantly share code, notes, and snippets.

@jseabold jseabold/bigmat.ado
Created Jan 12, 2012

What would you like to do?
Put a varlist into a matrix in Stata, even if matrix is bigger than matsize
Put a variable or variable list into a Stata matrix even if it's bigger than
If you have some variables xb1 and xb2
bigmat xb1 xb2, mat(new_mat)
You can check for new_mat by using
mat dir
capture program drop bigmat
program bigmat
version 11.0
syntax namelist(min=1), MAT(str)
mata: _bigmat("`namelist'", "`mat'")
void function _bigmat(string varlist, string Bigmat)
/* creates a matrix with name givem by bigmat */
real matrix Big
real matrix Data
V = st_varindex(tokens(varlist))
Data = J(1,1,0)
Big = J(rows(Data), cols(Data), 0)
for(i=1; i<=rows(Data); i++) {
for(j=1; j<=cols(Data); j++) {
Big[i,j] = Data[i,j]
st_matrix(Bigmat, Big)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.