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)" <>
To   "''" <>
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
/* - 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-----
[]On Behalf Of E. Michael
Sent: Thursday, November 04, 2004 10:36 AM
Subject: st: stata to winbugs

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

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

*   For searches and help try:
*   For searches and help try:

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