Hello, I am looking to fill a 4 by 5 matrix with the descriptive statistics (e.g. number of obs, max, min, sd, mean) of each variable. The objective is to fill each column with each variables statistics and utilize each row as a way to differentiate each variable. I would believe my code to be correct but every time I attempt to run it an "unexpected end of file" error occurs. If someone could help me out it would be excellent. The code is below:
I attempt to sum each variable separately through the tokenize, following this I attempt to utilize another foreach to extract scalars from the "sum" return and insert these values in the matrix, nevertheless, although I can extract the desired statistics the second loop, where I attempt to extract each statistic and insert it fails.
//
global areauso "area_uso_12 area_uso_14 area_uso_16 area_uso_17"
global numeroaños: word count $areauso
global colnames mean sd max min N
matrix stats = J($numeroaños,5,.)
matrix list stats
tokenize $areauso
foreach x of numlist 1/$numeroaños {
local j=0
sum ``x''
foreach y of global colnames {
local j=`j'+1
matrix stats[`n',`j']=r(`y')
}
}
//
Related Posts with Difficulties with loop in a loop, feeding a matrix values through a loop
. . …
value labels after appending datasetsHi all, I have 29 .csv dataset, each dataset is for a year from 1990 to 2018, and I want to append …
Independent sample t-testDear researchers, I have unbalanced panel data for a set of firms. In 2002 a new standard has been i…
Testing the null hypothesis that the skewness/kurtosis of 2 times series variable are the sameHi, I would like to test the null hypothesis that the skewness/kurtosis of 2 times series variable …
Using esttab and estout to Flip Models and Coefficients (tffects nnmatch coefs)Hi Stata ninjas, I am using estout documentation to develop a table that includes the coefficients …
Subscribe to:
Post Comments (Atom)
0 Response to Difficulties with loop in a loop, feeding a matrix values through a loop
Post a Comment