- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So I'm currently trying to export a SAS dataset as an xlsx file within the task scheduler on Windows 10.
The code works when manually ran in SAS, it works when I run the batch file outside of the scheduler, but once I try to have the scheduled task run at its time, the program is unable to export the file and instead keeps assigning a file type of $$1. I really don't know what else to try. The code of interest is below as well as the log from the scheduled task and the batch manuallyr ran.
Code:
Make sure the path name is correct and that you have write permission.
NOTE: "H:\05-25-23_Monitoring_Report.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.50 seconds
cpu time 0.12 seconds
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes. It has full admin rights. It works from that account both manually in SAS, when manually running the batch file, but just not in the scheduler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is that "Log from task scheduler" the SAS log? If so, it is incomplete. You should share the entire log, not just the error.
Since there is not result of your macro %put statement it is obvious that your log is incomplete.
Also I strongly suspect that the code you run from the scheduler is not the same. When %put the value of your outfile this is what I see:
178 %put outfile= "&webipath\&filename1" ; outfile= "H:\\05-24-23_Monitoring_Report.xlsx"
See the two \\? It may be that for what ever reason one version doesn't mind the the extra \ but the other does. So either drop the \ from the webipath value or from the Outfile. If you want to keep the \ in the webipath variable then use
outfile = "&webipath.&filename1"
Also, does the machine running the scheduler have the H: drive? Does the session running it have permissions to write there?
Question: why do you have that %let Filename1 inside of a data step? None of the code involved needs such.
174 %let webipath = H:\; 175 %let filename1 = %sysfunc(putn("&sysdate9"d,mmddyyd8.))_Monitoring_Report.xlsx; 176 %put &filename1; 05-24-23_Monitoring_Report.xlsx
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The scheduler calls the batch file, that works correctly when it is not called by the scheduler, so unless the scheduler is modifying the code, then it should be the same. Which is why I'm confused by it not working.
I fixed the double "\" and it still is providing the same error.
The machine running the schedule has the H:drive and has full read and write permissions.
I have the filename in a datastep, since there are multiple files being created in that step, filename1-filename5. I just removed those from the code when I posted since they weren't part of the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I suggest you double check the H drive existence by logging onto the machine running the SAS batch job with the same account used to schedule it just to confirm. Also try manually copying a file to the same H folder as a test. SAS obeys OS permissions so there is something going on at the OS level you might have missed.