I am using Stata 16 on Windows 10. I am running analyses (logit and mlogit) on 12 outcome variables, 11 exposure variables and 9 adjustment variables in three primary models. I've created a do file that successfully outputs my results to an excel file using putexcel. For each set of variables, I'd also like to use putexcel to output the frequency of the minimum "cell" size within the cross-tabulation of my my variable pairs. For example:
. tab sex group, matcell(x)
...........| Group
.......Sex | Sham Experiment | Total
-----------+----------------------+----------
......Male | 48 40 | 88
....Female | 29 38 | 67
-----------+----------------------+----------
.....Total | 77 78 | 157
. matrix list x
x[2,2]
....c1 c2
r1 48 40
r2 29 38
(Sorry about the inserted periods - I couldn't get the formatting correct.) For the above, the value I'd like returned would be 29. The matrices will vary from a 2X2 up to a 4X5 matrix.
I've tried:
. display min(x)
invalid syntax
r(198);
. generate minx=min(`x')
invalid syntax
r(198);
. generate minx = min(x)
invalid syntax
r(198);
. generate minx==min(x)
== invalid name
r(198);
But I obviously don't have something correct. I appreciate any help. Thank you.
Related Posts with Minimum (or Maxium) Value in a Matrix
generate variable: birth order of children (ages 0 to 17) in householdHello I am using the South African NIDS (National Income Dynamic Survey) wave 1 to wave 5. I have s…
Create mean variables of a subgroup for the whole groupDear all, I have data on education attainment per year and state and I want to compute the percenta…
cox regression with shared frailty or vce clusterHello, In running a cox regression model (stcox), I would like to look at within group correlation.…
Using the foreach commandHello, I am using STATA 15 and wide-format dataset. My aim is to create a new variable (my data is…
New version of xtdcce2 and xtcd2. New package xtcse2Thanks to Kit Baum a new version of xtdcce2 and xtcd2 is available on SSC. In addition a new program…
Subscribe to:
Post Comments (Atom)
0 Response to Minimum (or Maxium) Value in a Matrix
Post a Comment