BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hi folks,

I'm new to SAS, but not to programming, and am hoping you guys could help me out here! I am trying to automate some monthly reports via windows task scheduler, and a batch file. I'm running into an odd issue where I can run my sas script in the sas editor with no problem. However, if I run this same script through a batch file, the ODS PDF functions don't work. The batch file outputs the final dataset as a list file, and the data is correct, so the meat of the script is working correctly, it's just the ODS that I'm having trouble with. I'm using SAS 9.3 on a windows 7 machine.


The code is as simple as it can be:

ODS PDF file="C:\Users\user\Desktop\&sysdate..pdf";
   proc print data=finalname;
Ods PDF close;



The batch file looks like this:

pushd %~dp0\monthly\horseshoe
:: ----------------------------APPEND THE DATE TO THE FILENAME---------------------------------------------------
set reportname=Horseshoe_Monthly_Report_
set filename=%reportname%%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
"C:\Program Files\SASHome\x86\SASFoundation\9.3\SAS.exe"  -sysin "" -NOSPLASH -ICON -PRINT logs\%reportname%.lst -LOG logs\%filename%.log




The log file and the list file write, and the script does properly execute(except for the ods output).

The log file does show a few notes at the begining, these notes do not show if I run this script through the editor:

NOTE: Unable to open SASUSER.REGSTRY. WORK.REGSTRY will be opened instead.
NOTE: All registry changes will be lost at the end of the session.

WARNING: Unable to copy SASUSER registry to WORK registry. Because of this, you will not see registry customizations during this 
NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead.
NOTE: All profile changes will be lost at the end of the session.
[Note about license redacted]
NOTE: This session is executing on the W32_7PRO  platform.



And finally, a few notes appear around the proc print:

443        ODS PDF file="C:\Users\user\Desktop\&sysdate..pdf";
NOTE: Writing ODS PDF output to DISK destination "C:\Users\user\Desktop\06JUN16.pdf", printer "PDF".
NOTE: This SAS session is using a registry in WORK.  All changes will be lost at the end of this session.
444                                                                                proc print data=finalname;
445                                                                                run;
446                                                                                Ods PDF close;  



A few caveats:

First, I am not an administrator on the machine, which is what I am guessing the registry issues are from.

Secondly, I am not married to this work flow, it is just my initial experiment.

Lastly, I have tried other ods outputs, such as csv (assuming something was wrong with my pdf print drivers), and it will just write an empty csv file, albeit named correctly and in the correct directory. 


Any thoughts or ideas on directions I can take? Thanks for your help! 



My guess is you have an error earlier in the program which has triggered the batch sas default option SYNTAXCHECK. This mode switches SAS to not process any observations. Search through your SAS log for the key word ERROR and check the observation count notes for where your program first starts processing 0 observations.


The log notes you have in your post won't affect your program - they are for your information only. 

Fluorite | Level 6

I've been working with sas support guys for a bit on this problem, and they have come to the same conclusion as you: syntaxcheck mode. The problem is, the script still continues to process, and the final dataset that I am trying to output as a csv, has the correct observations in it. Somehow the final proc print inside the ods statements is what isnt running. Whatever the problem/incorrect syntax is, it is not stopping the script from executing, its not stopping the script from creating the correct dataset, it is causing no notes or errors of concern, its also running fine in the IDE. Only in batch mode does it seem to cause a problem. And, in batch mode, the dataset is correct, but the ods output is not. 


The program I am running is pretty old and vetted - something like 15 years+ in use. The problem is the original authors didn't care much for readability, making troubleshooting a chore. Thanks for all your help, I fear many hours of debugging ahead!


Calcite | Level 5

Having that exact same problem...will post if I find out what's going on. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3 in conversation