BookmarkSubscribeRSS Feed
Calcite | Level 5

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. 



%let webipath = H:\;
data _null_;
%let filename1 = %sysfunc(putn("&sysdate9"d,mmddyyd8.))_Monitoring_Report.xlsx;
%put &filename1;
PROC export data= Sample 
            outfile= "&webipath\&filename1" 
            DBMS=xlsx REPLACE;
Log error from task scheduler:
ERROR: Temporary file for XLSX file can not be created -> H:\05-25-23_Monitoring_Report.$$1.
Make sure the path name is correct and that you have write permission.
Log from batch, when ran outside of the task scheduler:
NOTE: The export data set has 17 observations and 265 variables.
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
Super User
Does the account used to run the scheduled tasks have the same access to H?
Calcite | Level 5

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. 

Super User

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;
Calcite | Level 5
So it isn't the full log. The majority of the log is the data steps between the creation of the code provided. To create the dataset that is trying to be exported.

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.
Opal | Level 21

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.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4 in conversation