<>
Well, it is instructive and big fun to rearrange the ` and ' and quotation
marks, and see what happens! You want the index "i" to be evaluated to the
number it represents within this loop. At the same time, you want -display-
to show the underlying strings left behind by -tokenize-, and thus need
quotation marks around this thing. Thus far, we have made it to -di in r
"`i'"- which would give you the numbers 1 to 5 in red...
The last step is to make -display- show the content of the -local- "1", not
the number, with the second evaluation within the quotation marks...
So try:
***
local mynames "nameone nametwo namethree namefour namefive"
token `mynames'
local mycount: word count `mynames'
forv i=1/`mycount'{
di in r "First attempt: " `i'
di in r "Second attempt: " "`i'"
di in r "Third attempt: " "``i''" _n(2)
}
***
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Donnerstag, 21. Januar 2010 16:06
An: [email protected]
Betreff: st: SV: AW: SV: AW: SV: AW: Output from tabulate to a matrix
Perfect, thanks again Martin.
Could you describe what´s happening in the last row of your syntax.
di in r "``i''"
/Tomas
-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Martin Weiss
Skickat: den 21 januari 2010 15:23
Till: [email protected]
Ämne: st: AW: SV: AW: SV: AW: Output from tabulate to a matrix
<>
Could well be as easy as
*************
local mynames "nameone nametwo namethree namefour namefive"
token `mynames'
local mycount: word count `mynames'
forv i=1/`mycount'{
//-lincom- statement goes here
di in r "``i''"
}
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Donnerstag, 21. Januar 2010 15:16
An: [email protected]
Betreff: st: SV: AW: SV: AW: Output from tabulate to a matrix
No. I have loop that repeats a lincom statement and I want to display a name
that is associated with the current lincom. Something like -display mynames
`i'-.
/Tomas
-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Martin Weiss
Skickat: den 21 januari 2010 14:43
Till: [email protected]
Ämne: st: AW: SV: AW: Output from tabulate to a matrix
<>
I am not quite sure what your intention is, but maybe you want to set row
and column names:
*************
clear*
matrix input mymat = (1,2,3,4\4,3,2,5\3,4,5,6\3,2,0,4)
mat l mymat
mat rownames mymat = north south west east
mat colnames mymat = north south west east
mat l mymat
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Donnerstag, 21. Januar 2010 14:30
An: [email protected]
Betreff: st: SV: AW: Output from tabulate to a matrix
Tanks Martin, it works fine.
Another question.
Is it possible to store names in a matrix for example "east", "west",
"north", "south" and then display the one that I want, for example the 3:rd
element "north"?
/Tomas
-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Martin Weiss
Skickat: den 21 januari 2010 14:07
Till: [email protected]
Ämne: st: AW: Output from tabulate to a matrix
<>
Those two missing column totals should read "4500" and "1000", I guess.
Ben`s -ssc d estout- may be helpful for you:
*************
webuse nhanes2b, clear
capture which estout
if _rc ssc install estout
estpost svy: tab race diabetes, col
mat l e(row)
di _b[Total:White]
di _b[Total:Black]
di _b[Total:Other]
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Donnerstag, 21. Januar 2010 13:26
An: [email protected]
Betreff: st: Output from tabulate to a matrix
Hi listers,
This syntax-
svy : tabulate area kon , count
produces a table like this (with 4 rows shown (fake data)).
area men women Total
--------------------------
aa 1200 1300 2500
bb 1100 900 2000
cc 4500
dd 1000
--------------------------
Total 10000
Key: weighted counts
Is it possible to divide all rowtotals with "totaltotal" (10000) and store
all these values in a matrix for later use?
How can I display a specific element of the stored values?
Yours
Tomas
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/