Stata Technical Bulletin
STB-20
. disp_s |
7 |
S_2: |
1 |
S_3: |
1994 |
S_4: |
Sat. |
Note that today did not mistakenly put “Sat.” in S_4. today happens to use only S_l-S_3, leaving S_4 from the lastday
command.
ip6 Storing variables in vectors and matrices
Ken Heinecke, Federal Reserve Bank of Kansas City, FAX 816-881-2199
mkmat takes the variables listed in varlist and stores them in column vectors; that is, N × 1 matrices where N = _N, the
number of observations in the data set. The syntax of mkmat is
mkmat varlist [if exp] [in range] [, matrix (mataame) ]
If the matrix() option is specified, the vectors are also combined in a matrix.
Discussion
Although it is possible to load variables into a matrix using the matrix accum command, programmers may find it more
convenient to work with the variables in their data sets as vectors instead of as cross products. mkmat allows the user a simple
way to load specific variables into matrices in Stata’s memory.
Example
. describe
Contains data from test.dta
Obs: 10 (max= 2562)
Vars: 3 (max= 200)
Width: 12 (max= 402)
1. x float 7,9.0g
2. y float 7,9.0g
3. z float 7,9.0g
Sorted by:
. list
x |
У |
z | |
1. |
1 |
10 |
2 |
2. |
2 |
9 |
4 |
3. |
3 |
8 |
3 |
4. |
4 |
7 |
Б |
Б. |
Б |
6 |
7 |
6. |
6 |
Б |
6 |
7. |
7 |
4 |
8 |
8. |
8 |
3 |
10 |
9. |
9 |
2 |
1 |
10. |
10 |
1 |
9 |
. mkmat y z
. matrix list y
y[10,l]
У
rl 10
r2 9
r3 8
r4 7
гБ 6
гб Б
г7 4
г8 3
г9 2
rlθ 1
. matrix list z
More intriguing information
1. THE CHANGING STRUCTURE OF AGRICULTURE2. Strategic Effects and Incentives in Multi-issue Bargaining Games
3. The name is absent
4. An Incentive System for Salmonella Control in the Pork Supply Chain
5. The name is absent
6. The open method of co-ordination: Some remarks regarding old-age security within an enlarged European Union
7. Land Police in Mozambique: Future Perspectives
8. NATIONAL PERSPECTIVE
9. The name is absent
10. The name is absent