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

I'm running SAS 9.4 on Windows. I have a loop that subsets the data, then runs proc surveymeans for the subset of data. The original code is shown below.

 

The data step runs successfully, but when the PROC SURVEYMEANS runs I get the error "ERROR: User does not have appropriate authorization level for library WORK". I ran it again after changing the library where the "exp_dat&m" datasets and the output datasets are stored to a different library, yet the same error related to the WORK library appears. When I reduced the number of repweights columns to 44, so the repweights option is wgt1-wgt44, the macro runs without error. 

 

  • Why does it say I do not have access to the library WORK even though I'm running SAS locally on Windows and should have full access to the WORK library?
  • Why does the same WORK related error message appear when I change the library to a different location?

 

Because it runs without error when there are only 44 repweights columns, I think the error has something to do with the amount of time the proc surveymeans takes. It usually takes 5ish minutes of the proc surveymeans running before the error shows up. Maybe some security system on my computer times out access after the process takes more than X minutes. If this is the case, is there a way I could break the processing into chunks so I can still use all 999 repweights columns. 

 

%macro loopsvm;
	%DO m = 1 %to 5;
	data exp_dat&m;
	set exp_dat;
	where IMPLIC = &m;
	run;
	
		PROC SURVEYMEANS DATA=exp_dat&m VARMETHOD=brr MEAN;
			WEIGHT wgt0;
			REPWEIGHTS wgt1-wgt999;
			VAR MORTGAGE RENT PROPTAX;
			DOMAIN igroup;
			ODS OUTPUT domain = Z&m;
		RUN; 
		DATA Z&m; SET Z&m; m=&m; RUN;
		ODS output close;
	%END;
	DATA mi_expvars_igroup; 
		SET Z:;
	RUN;
	PROC DELETE DATA=Z1 Z2 Z3 Z4 Z5; RUN;
	
%mend;
%loopsvm;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Usually that type of error is caused by some other process locking the file.  Check your Windows machine for Virus Scanning software or auto backup/archive software that might be locking the file.  See if you can disable them for the folder you are using for WORK.

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Usually that type of error is caused by some other process locking the file.  Check your Windows machine for Virus Scanning software or auto backup/archive software that might be locking the file.  See if you can disable them for the folder you are using for WORK.

eiger
Calcite | Level 5

I paused syncing to OneDrive and the program ran without a problem. Thanks!

ballardw
Super User

@eiger wrote:

I'm running SAS 9.4 on Windows. I have a loop that subsets the data, then runs proc surveymeans for the subset of data. The original code is shown below.

You should read the section in the online help in the syntax section of the BY statement about subsetting the data in the survey procs, such as you are doing, does not yield valid subpopulation analysis.

With Surveymeans the appropriate approach would be to add the subsetting variable(s) to the DOMAIN statement and then select the values as needed for your reports. You can have more than one variable on the Domain statement. The order of the variables does affect the order of the output data sets so may want to experiment.

 

Note that adding your IMPLIC variable to the Domain statement would also mean no Macro loop is needed. The syntax to get levels of Implic with each level of Igroup would be :

Domain Igroup * Implic ;

 

 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 394 views
  • 0 likes
  • 3 in conversation