BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LisaXu
Fluorite | Level 6

I need to schedule a daily SAS program run to check existence of a file and process it. Somehow, when I run the program in PC SAS , it can get the correct results. But when I use the Windows Task Scheduler to run it, it comes back "File does not exist". Same program. Anyone has any idea what could be wrong? Thanks so much!!

 

%let FileRef="R:\&filename";
%put &FileRef;
/**"R:\Account_2021-02-11.txt"**/
%let FR=%sysfunc(dequote(&FileRef));
%put &FR;
/**R:\Account_2021-02-11.txt**/

%macro CheckFile;
%if %sysfunc(fileexist(&FR)) %then %do;
data aa ;
infile &FileRef firstobs=2;
;
input  ............

 

run;
%end;
%else %put The file &FileRef does not exist. ;
%mend;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What is R: ?  Most likely you have mapped some network share to that drive letter as you probably do not have that many physical hard disks on your computer.

 

It seems likely that the scheduled job is running under a different user or at least setting up the Windows environment in a different way such that the R drive is not mapped (or if a different user then it does not have permission to see the requested file or the folder that holds it).

 

I would first try using UNC instead of mapped drive.  So if R: is mapped to \\some-server\some-share then change the code to:

%let FileRef="\\some-server\some-share\&filename";

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

What is R: ?  Most likely you have mapped some network share to that drive letter as you probably do not have that many physical hard disks on your computer.

 

It seems likely that the scheduled job is running under a different user or at least setting up the Windows environment in a different way such that the R drive is not mapped (or if a different user then it does not have permission to see the requested file or the folder that holds it).

 

I would first try using UNC instead of mapped drive.  So if R: is mapped to \\some-server\some-share then change the code to:

%let FileRef="\\some-server\some-share\&filename";
LisaXu
Fluorite | Level 6

Thanks so much for your quick reply, Tom! Yes, the R drive is what I mapped to save the long path...I'll fix that and see...Thanks again!!

LisaXu
Fluorite | Level 6

Impressive, Tom! You are right to the point! It worked! Really appreciate your help!!

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 658 views
  • 0 likes
  • 2 in conversation