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.
Any suggestions? Thanks!!
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.
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));
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.
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.
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;
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.