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

I just bumped into a scenario where a macro needed to write to a dataset, but the dataset was opened (in a window) and the macro threw this familiar error.

 

ERROR: You cannot open WORK.OUTPUT_DATASET.DATA for output access with member-level control because WORK.OUTPUT_DATASET.DATA is in use by you in resource environment ViewTable Window.

 

Ideally, I'd want the macro to prompt me to close the dataset (and maybe rename it) before proceeding. A 100% automated (silent) solution is not appropriate in this scenario. I'm sure I can cook up something functional, but thought I'd check with the community first in case a simple solution already exists.

 

Running SAS 9.4

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Wouldn't it be an option to use SAS Universal Viewer instead of ViewTables? This is what I use and recommend to avoid this problem (see, e.g., this thread: Close all VIEWTABLES).

View solution in original post

9 REPLIES 9
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

the one way to take care of that is to wright to a dataset with another name.

data want;

set have;

/* do a bunch of stuff */

run;

another way to take care of the problem is to make sure you close the datasets in SAS before trying to wright to them.

 

SAS can do a lot of things but this is a user error issue.

 

 

desertsp2
Calcite | Level 5

Thanks for the feedback.

 

Writing to another name would not be ideal, but could be done. I can test if the dataset is opened and dynamically create another name. This of course introduces other risks, what if that name isn't "legal" or another subsequent process is looking for the original name?

 

You're right though, this is a USER error I am trying to avoid!

ballardw
Super User

Environment and other user behaviors will affect how likely this can be done from code.

If you are running SAS in Display Manager (not SAS studio or Enterprise Guide) then the DM command lets you send commands to SAS.

In which case this may work:

dm "next viewtable:work.output_dataset ;end;";

 

The NEXT command needs to know the name of a window or it will likely access the wrong one. The End closes the window. You need a ; between commands and they entire command string must be within quotes. You should see the name of the window in the upper left corner if using Viewtable to open the table.

If using EG or SAS/Studio I have no idea what may work.

desertsp2
Calcite | Level 5

Thanks. I don't believe I'm running SAS in "Display Manager".

 

Here's the environment I'm working in...everything is local to my PC.

 

sas_screen.png

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

that looks like Base SAS DBCS

desertsp2
Calcite | Level 5

Correct about this being Base SAS. Unsure what DBCS stands for....double-byte character set?

ballardw
Super User

@desertsp2 wrote:

Thanks. I don't believe I'm running SAS in "Display Manager".

 

Here's the environment I'm working in...everything is local to my PC.

 

sas_screen.png


Yes that is the Display Manager.

FreelanceReinh
Jade | Level 19

Wouldn't it be an option to use SAS Universal Viewer instead of ViewTables? This is what I use and recommend to avoid this problem (see, e.g., this thread: Close all VIEWTABLES).

desertsp2
Calcite | Level 5

Thanks - I will look into that, seems like it has some other benefits as well.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 1562 views
  • 1 like
  • 4 in conversation