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

st: RE: Re: Stata and Excel


From   "Salvati, Jean" <JSalvati@imf.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: Stata and Excel
Date   Thu, 4 Nov 2004 17:32:51 -0500

I guess you could write an Excel macro that would do the following:

- Write a do file that would output results to a text file
- Call Stata in command-line mode to execute the do file
- Wait for the text file containing the results to be created (in C/C++,
the elegant way to do that is to use change notifications; in VB you may
have to use a loop that tries to open the file at regular time
intervals; I'm not sure)
- Read the text file containing the results

As an alternative to using a text file for the results, Stata could
output its results to a SQL database (see
http://www.stata.com/support/faqs/data/odbc_excel.html), and Excel would
pull the results out of that database using SQL queries. You might still
need to create a file somewhere to let Excel know that the results are
available. I worked on a system like that for my previous employer, but
the results were not produced by Stata.

Jean Salvati

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu 
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of 
> Friedrich Huebler
> Sent: Thursday, November 04, 2004 4:54 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Re: Stata and Excel
> 
> Yaseen,
> 
> Your message implies that you have Stat/Transfer. In your 
> do-file, you can save the results as a Stata data file and 
> then convert this file with -stcmd- to an Excel file. This 
> file could then be linked to your other Excel files.
> 
> save results.dta, replace
> stcmd stata results.dta excel results.xls /y
> 
> Friedrich Huebler
> 
> --- Yaseen Ghulam <Yaseen.Ghulam@port.ac.uk> wrote:
> > Dear Stata users,
> > 
> > Is there anyway of linking stata and MS Excel? I mean we 
> run the model 
> > from our do files, do the predictions and other 
> calculations and excel 
> > get the predicted values direcly from Stata. Our objective is to 
> > present these coefficents and predicted values in excel 
> pivot tables. 
> > One way may be creating log files or coping and pasting or 
> using stat 
> > transfer, but we are interested that excel should get the 
> values in a 
> > way as it gets values from other sheets or excel file.
> > 
> > Yaseen Ghulam
> > Lecturer Banking and Finance
> > University of Portsmouth
> > Economics Department
> > U.K.
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Check out the new Yahoo! Front Page. 
> www.yahoo.com 
>  
> 
> *
> *   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