Help using Base SAS procedures

Issue running SAS program through windows bat file

Reply
N/A
Posts: 0

Issue running SAS program through windows bat file

I have a working SAS program as below(basically uses proc sql to get metadata
for each dataset whose name appears in files dataset
------------------------------------------------------------------------------------------------
data _null_;

set files;

%let libLoc = TRIM(parentFolder);
%let dsName = TRIM(datasetName);
%let uDSName = UPCASE(&dsName);
%let opFile = TRIM(outputFileNameCSV);


%let tempLine = 'LIBNAME sasdata2 '''||&libLoc||''';' || 'data _NULL_;' || 'set sasdata2.'||&dsName||';' || 'run;' || 'ODS CSV FILE = '''||&opFile||''';' || 'proc sql;' || 'select * from dictionary.tables where memname='''||&uDSName||''';' || 'select * from dictionary.columns where memname='''||&uDSName||''';' || 'run;' || 'ODS CSV CLOSE;'
;

call execute(&tempLine);

run;
--------------------------------------------------------------------------------------------------
The above program runs fine through the SAS application and I get the metadata extracted in the appropriate csv files. But if I try to run the same program through a windows .bat file I don't see any output(No csv files created). My .bat file contains

------------------------------------------------------------------------------------------------
set program_path="C:\DAG\SAS\Tests\mySASProgram.sas"
set log_path="C:\DAG\SAS\Tests\mySASProgram.log"


"C:\Program Files\SAS\SASFoundation\9.2\sas.exe" -SYSPARM incov -SYSIN %program_path% -log %log_path%
------------------------------------------------------------------------------------------------

Any ideas on what I'm missing in the .bat file?

Thanks & Regards,
Neelam
Super Contributor
Super Contributor
Posts: 3,174

Re: Issue running SAS program through windows bat file

What does your SAS Log reveal about the SAS code being executed? Recommend you generate as much output for your executed code - add the following:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN ;

Then review the SASLOG output and if the problem is not obvious, then re-post a reply to this thread and paste the relevant SAS log (where code is executed) for additional diagnosis.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 1 reply
  • 114 views
  • 0 likes
  • 2 in conversation