Date: Mon, 4 Dec 2006 10:51:56 -0800
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject: Re: DOS Batch file to SAS communication
Content-Type: text/plain; charset="us-ascii"
Hi Raj,
You could have SAS stay in control of the
sequencing.
First, as you already have, SAS creates a
CSV file. Then you can set options for the
X command in SAS
OPTIONS XSYNC NOXWAIT;
and then use the X command to invoke your
DOS .bat file
X 'mydos.bat';
The control will XSYNC for the .bat to complete
and then fall back to SAS to continue on. If
the result is complete at the time the .bat is
done, then you should be able to open the result
and read it in. The NOXWAIT tells the dos command
window to close automatically when done, so that
human intervention is not needed to enter 'exit'
and <ENTER>.
Another alternative is if you can structure the
.bat to complete and return the results to the
console, then you could skip the OPTION and the X
and use the FILENAME token PIPE 'mydos.bat'; and
then when you input in from the token, the result
should be generated and returned to SAS.
Examples:
* make CSV file ;
data _null_;
file 'c:\temp\abc.csv';
put '"Fred","Wilma"';
put '"Barney","Betty"';
put '"Pebbles","BammBamm"';
run;
* make .bat file ;
data _null_;
file 'c:\temp\abc.bat';
put 'type c:\temp\abc.csv > c:\temp\xyz.txt';
run;
options noxwait xsync;
x 'c:\temp\abc.bat';
* read a text file with variable length records ;
filename yourfile 'c:\temp\xyz.txt';
data theds(keep=theline);
length theline $200;
infile yourfile length=lenvar;
input @1 theline $varying. lenvar;
run;
* or combine command and result together ;
filename yourfile pipe 'type c:\temp\abc.csv';
data theds(keep=theline);
length theline $200;
infile yourfile length=lenvar;
input @1 theline $varying. lenvar;
run;
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investment Group
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Raj
Sent: Monday, December 04, 2006 10:29 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: DOS Batch file to SAS communication
Hi RB,
Here is the program flow,
sas creates .csv file
calls .bat file sleeps for 30secs
wakes up to pick zip file n proceeds.
I am wondering if there is a way that batch file returns a value so that
sas does not have to do guess work and sleep.
Thank you,