BookmarkSubscribeRSS Feed
AlexeyS
Pyrite | Level 9

I want to update a protected table. Assume we have two users, and when I want to update the table, I need that second user will not open this table at the same time as me. Therefore I can use proc datasets.

 

The code looks like this: In the first proc step, I hold dataset_name, to prevent from second user to enter this table.

Then I update the table, and after that, I release the table. Can you see a problem with the code?

 

proc datasets lib= library_name;

modify dataset_name(pw=password);

quit;


data dataset_name;
set dataset_name dataset_name_new;
run;


proc datasets lib= library_name;
modify dataset_name(pw=password);
quit;

 

 

 

 

 

1 REPLY 1
Kurt_Bremser
Super User

There's two possible scenarios with regards to overwriting/updating a dataset:

  1. a user has that dataset open, eg in a viewtable. In this case, all write operations will fail.
  2. a user tries to access a dataset while you are writing to it. In that case, the user's attempt will fail until you are finished.

2) will not matter to you, but I guess that your code will still fail in 1), as SAS usually prevents all kinds of write access when a dataset is open, for whatever reason. The only method I've found (and AFAIK works only on UNIX) is to remove the target dataset with OS commands before you write to it.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 929 views
  • 0 likes
  • 2 in conversation