BookmarkSubscribeRSS Feed
Aexor
Lapis Lazuli | Level 10

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.

5 REPLIES 5
SASJedi
SAS Super FREQ

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.

 

 

 

Check out my Jedi SAS Tricks for SAS Users
Aexor
Lapis Lazuli | Level 10
Thank you for your response.

Just wanted to add here that The X macro variable can have other values Like Public and other CAS libs

This macro is not working when I pass the X value as Public
SASJedi
SAS Super FREQ

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. 

Check out my Jedi SAS Tricks for SAS Users
Aexor
Lapis Lazuli | Level 10
Thanks. Yes my bad .let me add some more .

I have source name as InventoryFulfillment

though it is throwing error for libname but other operation worked fine. I am not getting what is actual issue.

normal: SYMBOLGEN: Macro variable MP_SOURCENAME resolves to InventoryFulfillment
normal: SYMBOLGEN: Macro variable VF_LIB resolves to InventoryFulfillment
normal: SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.
error: ERROR: InventoryFulfillment is not a valid SAS name.
error: ERROR: Error in the LIBNAME statement.

normal: MPRINT(X): proc casutil;
note: NOTE: The UUID '227b59b2-fcf9-e64a-aa96-e6abec55e82e' is connected using session CASAUTO.
normal: SYMBOLGEN: Macro variable PLAN_LIB resolves to planning
normal: SYMBOLGEN: Macro variable INPUTTABLE resolves to OUTFOR_102
normal: SYMBOLGEN: Macro variable INPUTTABLE resolves to OUTFOR_102
normal: SYMBOLGEN: Macro variable VF_LIB resolves to InventoryFulfillment
normal: SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.
normal: MPRINT(X): load data =planning.ed_OUTFOR_102 CASOUT="ed_OUTFOR_102" OUTCASLIB="InventoryFulfillment" replace;
note: NOTE: PLANNING.ED_OUTFOR_102 was successfully added to the "InventoryFulfillment" caslib as "ED_OUTFOR_102".

normal: MPRINT(X): create table InventoryFulfillment.tmp_OUTFOR_102 as select a.* ,b.time_id as start_dt_sk from
normal: InventoryFulfillment.OUTFOR_102 a, InventoryFulfillment.ed_OUTFOR_102 b where a.start_date between b.start_date and b.end_date;
note: NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION
note: column will be created instead. A DATE format will be associated with the column.
note: NOTE: Table TMP_OUTFOR_102 was created in caslib InventoryFulfillment with 779282 rows returned.
normal: MPRINT(X): quit;
SASJedi
SAS Super FREQ

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. 

 

 

Check out my Jedi SAS Tricks for SAS Users

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 628 views
  • 4 likes
  • 2 in conversation