Date: Mon, 20 Oct 2003 07:55:24 -0400
Reply-To: Ben Powell <ben.powell@CLA.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ben Powell <ben.powell@CLA.CO.UK>
Subject: Re: In search of automation - SAS Base/Unix
Dear Howard, with the push of a button -- exactly! I've got the
functionality down now, although it is a bit of a spider's web (1 program,
7 macros and submacros, 3 .exes by X, 3 vbs scripts and 2 batch files and 2
ftp scripts all by X) which I should probably tidy up a bit. All in all 3
parameters are required and a further 5 or so are generated.
Here is the top level macro below, including the ftp engine waits but none
of the scripts or sub-macros. In order to produce the report, sas checks 2
files on the sun server by X and vbs, then ftps a file to sun where oracle
validates the data; sas detects when this is complete and tells oracle to
run a second report, which again is detected on completion and the results
imported and archived.
options macrogen;
%macro mac2_validation_test;
%let vbs_script = P:\SAS\PROJECTS\Ftp\bkm_load_ora_&type..vbs;
%let exportdataset = preldist.&MMMYY.&type._bkm;
%let bkmset = &MMMYY.&type._bkm_f;
/*RENAME OLD COPIES OF FILES;IF NOT FOUND THEN NO ERROR*/
options noxsync; /*REQUIRED TO ALLOW TTERMPRO TO PROCESS VBS*/
x '"C:\Program Files\TTERMPRO\ttermpro.exe" SUN01';
data _null_;call sleep(500);run;
x 'P:\SAS\PROJECTS\Combined_Prel_Dist_tests\Progs\rename_combined.vbs';
options xsync; /*NO LONGER REQUIRED FOR REST OF PROGRAM*/
options noxwait;
/*WAIT FOR RENAME TO COMPLETE*/
data _null_;call sleep(10000);run; /*REQUIRED*/
/*EXPORT TO VALIDATION*/
%include 'P:\SAS\Macros2\mac2_export_to_validation.sas';
/*LOOP AND WAIT FOR NEW FILE*/
filename abc ftp '' cd="/u02/survey/test/" ls user='XXXXXX'
host='sun01' pass='XXXXXX';
%macro doit;
%global nowdone;
%let nowdone=0;
%doagain:;
data _null_;
call sleep(20000);
run;
data test; infile abc;
length x $25.;
input x $;
if x='validated.dat'
then call symput('nowdone','1');
run;
%if &nowdone.^=1 %then %goto doagain;
%mend;
%doit;
/*RUN test*/
%include 'P:\SAS\Macros2\mac2_run_v_test.sas';
/*LOOP AND WAIT FOR NEW FILE*/
filename abc ftp '' cd="/u02/survey/test/bkmast/" ls user='XXXXXX'
host='sun01' pass='XXXXXX';
%macro doit2;
%global nowdone;
%let nowdone=0;
%doagain:;
data _null_;
call sleep(20000);
run;
data test; infile abc;
length x $25.;
input x $;
if x='combined_bkm.dat'
then call symput('nowdone','1');
run;
%if &nowdone.^=1 %then %goto doagain;
%mend;
%doit2;
/*GET NEW FILE*/
%include 'P:\SAS\Macros2\mac2_import_v_test.sas';
/*END - test ARCHIVED*/
%mend;
%mac2_validation_test;
Date: Thu, 16 Oct 2003 13:00:38 -0400
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: In search of automation - SAS Base/Unix
This reminds me of Ray's "And All With the Push of a Button !".
http://www.nesug.org/Proceedings/nesug98/appl/p072.pdf
On Thu, 16 Oct 2003 08:05:59 -0400, Ben Powell <ben.powell@CLA.CO.UK> wrote:
>Dear SAS-L,
>
>I've got the following code snippet that will run a report in three
>stages. It includes various macros and submacros and executes vbs
>scripts that run scripts on oracle which in turn validate a dataset
>(exported via ftp), then run a report against it. Finally another vbs
>script (executed by the X
>command) imports (via ftp) the final report dataset and archives it to the
>project lib.
>
>What I am wondering is whether it is possible to run these snippets in
>a second SAS instance and go away and buy a coffee and come back and
>have it all done. Currently, I wait for oracle to finish each of the
>two reports (validation and final report) before I can run the macros
>and vbs scripts. Is there a code loop I can run to check the Sun Server
>(where the Oracle database lives) for signs that the requested file has
>been updated, and tell SAS when to execute the next line of code? Or is
>there something I can run instead on the Sun Server - the latter is not
>something I've done before. Obviously keeping it as much within SAS is
>ideal. The ftp and vbs scripts were only used out of necessity, i.e. no
>ODBC, etc, just SAS Base.
>
>Code below,
>Any help much appreciated.
>
>%let path=P:\SAS\PROJECTS\Combined_Prel_Dist_as;
>libname preldist "&path\SDS";
>
>*enter month and year MMMYY;
>%let MMMYY = oct03;
>*enter bk or jl;
>%let type = bk;
>
>%let exportdataset = &MMMYY.&type._bkm;
>%let bkmset = &MMMYY.&type._bkm_f;
>
>%include 'P:\SAS\Macros2\mac2_export_to_validation.sas';
>/*WAIT FOR ORACLE COMPLETION PRIOR TO CONTINUING*/
>%include 'P:\SAS\Macros2\mac2_run_v_a.sas';
>/*WAIT FOR ORACLE COMPLETION PRIOR TO CONTINUING*/
>%include 'P:\SAS\Macros2\mac2_import_v_a.sas';
>/*END - a ARCHIVED*/
------------------------------