I am trying to do a bootstrap sample of variables in a macro do loop. The code is similar to the macro shown below (NOTE: the code below works fine. It is the real dataset, which I cannot share here, where the problem occurs):
%Macro test();
%Do x = 1 %to 10;
data cars;
set sashelp.cars;
run;
Proc surveyselect
Data=cars
Method=urs
Seed=90
Samprate=0.5
Reps=100
Out=cars_sample;
Run;
/*Do something with the sample for each iteration*/
%End;
%Mend;
On the second iteration SAS tell me that the dataset is locked:
ERROR: You cannot open WORK.CARS_SAMPLE.DATA for output access with member-level control because WORK.CARS_SAMPLE.DATA is in use
by you in resource environment IOM ROOT COMP ENV.
The dataset is certainly not open by any other user (this is confirmed because when I close SAS and start the session again the dataset unlocks), neither is it open by me in any other program.
How can I solve this issue?
Set Enterprise Guide to not automatically open result datasets for viewing.
Do you mean tools - options - data general - Automatically import data when added to project? Or something else?
It is in Tools - Options - Results General - automatically open Data or Results (rough translation, my EG 7.15 is set to German)
My version is 8.1 and there is no such option
If you are using EG 8, it would look something like the below.
Jim
Thank for the reply, but unfortunately it does not work
Try making a different dataset each time through the loop.
%do x = 1 %to 10;
...
Out=cars_sample&x
...
An aside, when you use a specific seed value in Proc Surveyselect with the same input data set and other options/parameters the resulting data is exactly the same. So running that particular Surveyselect code generates the same data set 10 times.
I know you are saying "like this" but if the code is close enough to the example there is a certain amount of repeating the same thing for the exact same sample.
And the likely issue is in the
/*Do something with the sample for each iteration*/
Possibly one of the procedures like Proc Datasets or Document that expects a Quit statement to end the procedure.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.