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
How to rotate Stata -by- group graph horizontallyHi Statalist members, I was wondering if there's a way to replicate this R gglot graph in Stata in …
How to convert back from levelsofI have a variable which has type int but each int is corresponding to a word that is meaningful, and…
DSGE error(498): could not find steady-state of model under initial parameter vectorHello everyone, I'm trying to run a non-linear DSGE model but I'm facing an error saying "could not …
Converting data structure to a panel data structureHi all, I am trying to analyze a panel dataset. The data has three years of observations (2016, 2018…
Dichotomous Logistic ModelHi there Would be grateful for advice on how to fit and predict my model that has two outcomes: 1 co…
Subscribe to:
Post Comments (Atom)
0 Response to Difficulties with loop in a loop, feeding a matrix values through a loop
Post a Comment