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

Re: st: getting Stata to wait until a shell command is finished

From   "Isaías H. Salgado Ugarte" <>
Subject   Re: st: getting Stata to wait until a shell command is finished
Date   Wed, 19 Jun 2002 14:16:31 -0500

> Dear Gabriel:

> I am not sure if the following experience may serve, but...if you are
> working in Windows platforms...

> You are rigth. Stata does not wait for another program to finish in
> order to do the calculations inside an ado file. It is necessary to do
> Stata confirm the existance of a file. Some time ago (when the Windows
> version for Stata appeared), I had that kind of problem and the
> technical advice lead me to the following code:
> winexec dosprmpt.pif /c l2cvwarw
>  capture confirm file signfile
>  while _rc ~=0 {
>            capture confirm file signfile
>  }
>  erase signfile

In your external (to Stata) code you must create the "signfile" as the
last step.

Hope this help

Isaías H. Salgado-Ugarte

> Gabriel Demombynes wrote:
>> In the middle of my Stata program, I need to call a SAS batch
>> routine (in
>> Windows) and then have Stata wait until the SAS routine is finished,
>> so that
>> it can use part of the SAS output. However, when I use the shell
>> command to
>> call batch SAS, the SAS routine starts, and Stata doesn't wait. How
>> can I
>> get Stata to wait? I've tried using the sleep command, but then I
>> have to
>> guess how long SAS is going to take, and that time varies.
>> I think what I need to do is have Stata check for the existence of
>> the SAS
>> output file as a condition for continuing, and have it continue to
>> sleep if
>> the file doesn't exist. I'm sure Stata must have a logical command
>> that
>> checks for the existence of a file, but I can't find it. I did find
>> the
>> confirm command, but I can't figure out how to use its output.
>> Please help!
>> Thanks,
>> Gabriel
>> Gabriel Demombynes
>> Ph.D. Candidate
>> Department of Economics
>> University of California-Berkeley
>> *
>> *   For searches and help try:
>> *
>> *
>> *

*   For searches and help try:

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