Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: stata to winbugs


From   "FEIVESON, ALAN H. (AL) (JSC-SK) (NASA)" <alan.h.feiveson@nasa.gov>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: stata to winbugs
Date   Thu, 4 Nov 2004 11:50:49 -0600

Michael - 

I do  have a rudimentary program for writing out all observations of a
variable with commas as separators and putting as many on a line as you
desire - so you can then paste this into a bugs .odc page. Of course you are
responsible for sorting the data in the approriate order.

Here it is: The first argument is the variable name; the second ones is the
number of observations per line of output.


version 7.0
/* bugwrite.do - writes stat variable `y' in bugs format with `k'
values per row */
args y k

local N=_N
if mod(`N',`k')==0 {local r = `N'/`k'}
if mod(`N',`k')>0 {local r =1+int(`N'/`k') }
forv i=1(1)`r'{
   local i1=1+`k'*(`i'-1)
   local i2=`k'*`i'
   if `i2' > `N' { local i2=`N'}
   local a ""
        forv j=`i1'(1)`i2' {
           if `j' < `N' {
           local a="`a'"+ string(`y'[`j'])+","
           }
           if `j' == `N' {
           local a="`a'"+ string(`y'[`j'])+")"
           }
        }
   noi di "`a'
   }

Hopefully, this can be of some use.

Al Feiveson
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of E. Michael
Foster
Sent: Thursday, November 04, 2004 10:36 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: stata to winbugs


Hi,
  Does anyone have a handy-dandy do file for exporting STATA data into a
format WinBugs can read? 
thanks,
Michael

E. Michael Foster
Professor of Health Policy and of Demography
Methodology Center and Department of Health Policy
Penn State


*
*   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/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index