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

I have a batch that will read data from an excel file on a daily basis, and run the programs whose filepath is included in the file. This will make it easier to add new programs to the batch, and keep track of which programs have a batch job. 

 

Few people have access to the excel-file, and getting a lock would be quite rare, as the batch runs outside of working hours. Still, I was wondering if there is a way to read the file even if the excel file is opened by someone. There doesn't seem to be a sas-spesific way to do this, but I can sort of imagine how to write this as a shell script that either runs is the file has a lock, as a X-command, or just writing a standalone shellscprit that either forces a close or makes a copy, so that the batch can import the file with the contents of the previously saved file. 

 

Is there a standard best practice for such situations? 

1 ACCEPTED SOLUTION

Accepted Solutions
Ullsokk
Pyrite | Level 9

On second thought, I might as well just make a copy and read that file instead. No need to run a condition beforehand

View solution in original post

8 REPLIES 8
Kurt_Bremser
Super User

Don't keep such control data in a spreadsheet file, use a text file instead, and edit it with a text editor.

Notepad++ or the standard Windows Editor (just to give some examples) do not lock the file.

Ullsokk
Pyrite | Level 9

That will probably not be an option in my case. In any case, I am planning to use a x-command to create a temporary copy of the file if it is already open. The only problem is getting SAS to check if the file is already open.

andrewboyd
Fluorite | Level 6

Have you tried testing this to see what happens? I ask because as you aren't writing back to the excel file I can't see why there would be an issue as sas would presumably just get a read only version of the file just as a user would when they open a worksheet already opened by another user.

Ullsokk
Pyrite | Level 9

On second thought, I might as well just make a copy and read that file instead. No need to run a condition beforehand

AlanC
Barite | Level 11

Write a Powershell script to kill the task.

https://github.com/savian-net
error_prone
Barite | Level 11

@AlanC wrote:

Write a Powershell script to kill the task.


Hardly possible to do in a Client-Server-Setup, the task locking the Excel-file will most likely not be running on the same machine as the sas process.

AlanC
Barite | Level 11

Powershell can be executed remotely. However, I don't think we have enough informationas to the configuration of the system in question here.

https://github.com/savian-net

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 8 replies
  • 5147 views
  • 2 likes
  • 5 in conversation