mdgross/mdgrosscuff--
It's not clear exactly what you want here, or why, but let's suppose
you've already -infile-d your text file matrix (see -help infiling-)
and you want to reshape your data, which looks like this at the start:
row v1 v2 v3 v4 v5
1 0.00000 0.12704 0.06991 0.00000 0.09954
2 0.21727 0.00000 0.18285 0.00000 0.29448
3 0.26031 0.26513 0.00000 0.00000 0.29448
4 0.00000 0.00000 0.00000 0.00000 0.00000
5 0.27872 0.30490 0.25021 0.00000 0.00000
so you can -reshape- your data,
and then -generate- variables to get what you want:
reshape long v, i(row) j(col)
gen why=string(col)+char(96+row)
gen not=v if row!=col
replace not="x" if mi(not)
sort why
li, noo clean
row col v why not
1 1 0.00000 1a x
2 1 0.21727 1b 0.21727
3 1 0.26031 1c 0.26031
4 1 0.00000 1d 0.00000
5 1 0.27872 1e 0.27872
1 2 0.12704 2a 0.12704
2 2 0.00000 2b x
3 2 0.26513 2c 0.26513
4 2 0.00000 2d 0.00000
5 2 0.30490 2e 0.30490
1 3 0.06991 3a 0.06991
2 3 0.18285 3b 0.18285
3 3 0.00000 3c x
4 3 0.00000 3d 0.00000
5 3 0.25021 3e 0.25021
1 4 0.00000 4a 0.00000
2 4 0.00000 4b 0.00000
3 4 0.00000 4c 0.00000
4 4 0.00000 4d x
5 4 0.00000 4e 0.00000
1 5 0.09954 5a 0.09954
2 5 0.29448 5b 0.29448
3 5 0.29448 5c 0.29448
4 5 0.00000 5d 0.00000
5 5 0.00000 5e x
On 5/8/06, [email protected] <[email protected]> wrote:
I am trying to create a variable to represent a matrix.
I have the following text files:
<snip>
Any suggestions as to the general direction I should pursue would be greatly appreciated.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/