BookmarkSubscribeRSS Feed
sahoositaram555
Pyrite | Level 9

Hi experts,

I have libname statements for folder1...folder10. Each folder have some .sas7bdat files.

I need to pick some .sas7bdat files of my interest from the folder of my choice and merge them later. So, for the below written macro statements i need help to figure out why the macro is not getting resolved.

%let file_a=randomisation;

%let file_b=Screening;

data rand;
merge folder5.&file_a.(in=a)  folder6.&file_b.(in=b);
by PatientInitials;if a=1;
run; 

ERROR: User does not have appropriate authorization level for file FOLDER5.RANDOMISATION.DATA.

ERROR: User does not have appropriate authorization level for file FOLDER6.SCREENING.DATA.

 

but it works,when i do below:

data a;set folder5.randomisation;run; 

data b;set folder6.screening;run; 

then, data rand;merge a b;by var;run;

 

Can anybody explain why merge statement doesn't directly resolves folder5.&file_a. and folder6.&file_b?

2 REPLIES 2
Tom
Super User Tom
Super User

Show the lines from the LOG. Make sure to use the Insert Code button (looks like < / > ) so you get a pop-up window to paste the lines so the formatting is preserved.

 

The error message makes it sound like you let the semi-colon off the end of your data statement so that it thought you wanted to create those datasets instead of read from those datasets.

Code like this

data rand merge folder5.&file_a. folder6.&file_b. ;

is instructions to create four datasets: rand, merge and the other two.

ChrisNZ
Tourmaline | Level 20

You are not showing the problem.

The macro variables get resolved as indicated by the error messages.

Show us the codes and the logs.

The error points to an authorisation issue, so I suspect the libname folders are different, or the table creators are different, or something along these lines.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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