Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: ouput tables using command 'display'


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: ouput tables using command 'display'
Date   Mon, 30 Jan 2006 08:52:03 -0000

Jackie

I think the little trick you are looking for is -_continue- (or -_c-) in
the -display- command - this prevents Stata from starting a new line.
You could then write something like...

forvalues i = 12/51 {
    forvalues j = 11/38 {
        display `t4a_`i'`j'' "," _c
    }
    display
}

Hope this helps

David 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Hui Wang
Sent: 29 January 2006 23:06
To: [email protected]
Subject: st: ouput tables using command 'display'

Hi, Guys,

I am trying to do a table contenting condictional counting results in
each cell. To output the table automatically, I want to save the count
result in macros and then use 'display' to show them in rows and
columns.

The following is the main code. Where each row is the individual's
current age and each column is the age at marriage, so that the number
in row i and column j represents the number of people who is i years old
now got married when he is j years old.

******Counting*********************************************
forvalue i=12/51 {
   forvalue j=11/38 {
   count if age==`i' & marr_age==`j'
   local t4a_`i'`j'=r(N)
   }
}

*****Display***********************************************
forvalue i=12/51 {
  display `t4a_`i'11' ","	`t4a_`i'12' ","	`t4a_`i'13' ","
`t4a_`i'14' 
","	`t4a_`i'15' ","	`t4a_`i'16' ","	`t4a_`i'17' ","	`t4a_`i'18' 
","	`t4a_`i'19' ","	`t4a_`i'20' ","	`t4a_`i'21' ","	`t4a_`i'22' 
","	`t4a_`i'23' ","	`t4a_`i'24' ","	`t4a_`i'25' ","	`t4a_`i'26' 
","	`t4a_`i'27' ","	`t4a_`i'28' ","	`t4a_`i'29' ","	`t4a_`i'30' 
","	`t4a_`i'31' ","	`t4a_`i'32' ","	`t4a_`i'33' ","	`t4a_`i'34' 
","	`t4a_`i'35' ","	`t4a_`i'36' ","	`t4a_`i'37' ","	`t4a_`i'38' ","
}

The results looks likt the following:

<snip>

In the display part, I only use loop structure for the rows but not the
columns, which makes the programming a bit complicated to write.

So my question is that is there any way that I can also write a loop
structure for the columns to get the same output results as above? How
to use more than one loop in the display command so that the program can
out put the table that I want?

Thank you very much!

Jackie

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index