BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
J111
Quartz | Level 8

Hello,

we are able to extract the last modified date of a file on Linux using the following code,

and we would like to extract similar information from a web server/ local.

 

* Running on a Linux folder ;

filename myfile '/opt/sas/spf/xyz/abc.csv' ;
 
data last_updated ;
   opt=FOPTNAME(FOPEN('myfile'),5) ;
   optval=FINFO(FOPEN('myfile'),upcase(opt)) ;
run ;

Here we get the required information

Last Modified 31Jan2023:15:29:01

However a log ERROR appears for running on a web server/windows  :

 

filename fileref 'C:\Temp\abc.csv' ;                                                                                                          
data a(drop=fid);                                                                                                                       
   infile fileref truncover obs=1;                                                                                                       
   fid=fopen('fileref');                                                                                                                 
   moddate=finfo(fid,'Last Modified');                                                                                                   
run;        

ERROR: Physical file does not exist, /opt/sas/config/Lev1/SASApp/C:\Temp\abc.csv.

 

Do we need to install Samba in order to solve this issue ? another solution you might have ?

What would the code be ?

Thanks a lot

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

It looks like the file you are referencing is not on the server, but on a local C drive. Since SAS is running on the server, it cannot "see"/access the files on your local machine. For this to work, those files would need to be somewhere that the SAS server can access. If your SAS is running on Linux, then this could be a network file share/Samba share (which you mentioned).

 

The main thing to remember is that all file references in SAS code must be coded to access from the SAS environment, not your local machine, if the SAS environment is running on a central server.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

3 REPLIES 3
ChrisHemedinger
Community Manager

It looks like the file you are referencing is not on the server, but on a local C drive. Since SAS is running on the server, it cannot "see"/access the files on your local machine. For this to work, those files would need to be somewhere that the SAS server can access. If your SAS is running on Linux, then this could be a network file share/Samba share (which you mentioned).

 

The main thing to remember is that all file references in SAS code must be coded to access from the SAS environment, not your local machine, if the SAS environment is running on a central server.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
J111
Quartz | Level 8

Hello, We get the same error if the csv is local or if it is located on the web and not at the Linux server.

Thanks your reply is helpful.

 

Tom
Super User Tom
Super User

@J111 wrote:

Hello, We get the same error if the csv is local or if it is located on the web and not at the Linux server.

Thanks your reply is helpful.

 


Do you get the error the FIRST time you run that code? Or the only on the second, third, etc ?

 

You did not CLOSE the file you OPENED.

data a(drop=fid);
   infile fileref truncover obs=1;
   fid=fopen('fileref');
   moddate=finfo(fid,'Last Modified');
   fid=fclose(fid);
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 743 views
  • 3 likes
  • 3 in conversation
OSZAR »