Hi All,
I need your help in below syntax.
I am using below code to assign a CASLIB
%let x = &source
libname &x cas caslib="x";
I am getting error in libname statement. I have attached log details below:
normal: SYMBOLGEN: Macro variable source resolves to CASUSER(CMSTEST)
normal: SYMBOLGEN: Macro variable x resolves to CASUSER(CMSTEST)
error: ERROR: Libref CMSTEST is not assigned.
error: ERROR: Error in the LIBNAME statement.
Please let me know what went wrong here. How can I resolve this issue.
In CAS, the name of the CASUSER caslib often has the userID of the caslib owner included in parentheses. In your example, the userID appears to be CMSTEST, so the name appears like this: CASUSER(CMSTEST). Of course, that would not be valid as a SAS libref. So, if the value of SOURCE is CASUSER(CMSTEST), when you submit this code:
%let x = &source
libname &x cas caslib="x";
after the macro variable resolved, the code looks like this:
libname CASUSER(CMSTEST) cas caslib="x";
That's not valid syntax, so the code fails to run. What you really need is for the resolved code to look like this:
libname CASUSER cas caslib="CASUSER(CMSTEST)";
You can accomplish that by scanning out the first part of the &x value as the libref, and using &x in the caslib= option like this:
libname %qscan(&x,1,%str(%(%))) cas caslib="&x";
I hope this helps.
When you say that something isn't working you need to provide more than just a verbal description to get additional help. Please proved a sample of the simplest code you can that demonstrates the problem, along with all of the log messages generated. For example, I ran this code in SAS Viya:
%let source=Public;
%let x=&source;
libname %qscan(&x,1,%str(%(%))) cas caslib="&x";
and it produced these results in the log:
80 %let source=Public;
81 %let x=&source;
82 libname %qscan(&x,1,%str(%(%))) cas caslib="&x";
NOTE: Libref PUBLIC was successfully assigned as follows:
Engine: CAS
Physical Name: f64402f2-bb59-d94c-84ac-f4ac417d4986
As you can see, this code is working as expected with a source value of 'Public'.
So before we can troubleshoot further, you'll need to share your actual code and log. It would be helpful to print the values of source and x to the log just before the LIBNAME statement is generated.
The reason this doesn't work is given in the log:
error: ERROR: InventoryFulfillment is not a valid SAS name.
A caslib name can be up to 256 characters long, but a SAS libref has a maximum length of 8 characters. So InventoryFulfillment is valid as a caslib name but is not valid as a libref. You still have not shared your code so more specific help is not possible, but when you assign the libref to the caslib, you will need to supply a libref value that meets the 8-character maximum criteria.
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.