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

I keep getting this message after using %SYSFUNC:

ERROR: You cannot open WORK.OUT_14.DATA for output access with member-level control because WORK.TEMP_DATA.DATA is in use by you

in resource environment DMS Process.

I tried to make a macro variable to show how many columns in my SAS dataset. I used the code:

%let nvar=%sysfunc(attrn(%sysfunc(open(work.temp_data,i)),nvars));

but after using this code, I cannot modify TEMP_DATA any more. Smiley Sad

Any suggestions? Thanks!!

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Still just guessing without seeing your code, but how about?:

%let dsid=%sysfunc(open(labimp.muestra1,i));

%let nvar=%sysfunc(attrn(&dsid.,nvars));

%let rc=%sysfunc(close(&dsid.));

p.s.  You'll probably have to start a new SAS session because, now, you have a number of opened files.

View solution in original post

5 REPLIES 5
art297
Opal | Level 21

I don't think %sysfunc is your problem but, rather, that you have opened and not closed the file.  Try issuing the following (untested) right after the line where you get the number of variables.  Without seeing your code I'm not sure how you would have to call it:

%let rc=%sysfunc(close(work.temp_data));


Ken_oy
Fluorite | Level 6

It doesn't work. Getting the following error:

ERROR: Argument 1 to function CLOSE referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.

ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list.  Execution of %SYSCALL statement or

       %SYSFUNC or %QSYSFUNC function reference is terminated.



------------------EDITED----------------


I also tried %sysfunc on my other datasets.

Getting the same error when I tried to modify the dataset again.

art297
Opal | Level 21

Still just guessing without seeing your code, but how about?:

%let dsid=%sysfunc(open(labimp.muestra1,i));

%let nvar=%sysfunc(attrn(&dsid.,nvars));

%let rc=%sysfunc(close(&dsid.));

p.s.  You'll probably have to start a new SAS session because, now, you have a number of opened files.

Ken_oy
Fluorite | Level 6

Thanks Arthur! Your code works.

It seems like that I have to use %sysfunc(close() ) to close the opened file. Am I correct?

I used the following code to do the test. If I did not apply the %sysfunc(close() ) line, I would still get the same error.

--------------------------------------------

data temp_data2;

input t1 t2 t3; datalines;

1 2 3

;run;

%let dsid=%sysfunc(open(work.temp_data2,i));

%let nvar=%sysfunc(attrn(&dsid.,nvars));

%let rc=%sysfunc(close(&dsid.));

%put &nvar;

Tom
Super User Tom
Super User

Close those open datasets!

Normally SAS just generates sequential fileid numbers so you can try running something like this to close any that might have open.

data _null_;

do i=1 to 100;

   rc=close(i);

   put i= rc=;

end;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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