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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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