Help using Base SAS procedures

Issue running SAS program through windows bat file

Not applicable
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);

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\"
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,
Super Contributor
Super Contributor
Posts: 3,176

Re: Issue running SAS program through windows bat file

Posted in reply to deleted_user
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:


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
  • 2 in conversation