BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to understand how Call Execute works.. I tried a very simple program which creates a library reference

Below is sample code..

data _null_;
set files;
call execute('LIBNAME sasdata2 ''C:\DAG\SAS\Samples\'';'
);

run;

It runs fine with following in the log -

+ LIBNAME sasdata2 'C:\DAG\SAS\Samples\';
NOTE: Libref SASDATA2 was successfully assigned as follows:


Now if I change my code to use a variable instead of actual string value for libname
as below

data _null_;
set files;
call execute('LIBNAME sasdata2 '''||folderName||''';'
);

run;

I get the following -

NOTE: CALL EXECUTE generated line.
1 + LIBNAME sasdata2 'C:\DAG\SAS\Samples\
2 +
WARNING: The quoted string currently being processed has become more than 262 characters long. You may have
unbalanced quotation marks.
3 + ';
ERROR: Invalid physical name for library SASDATA2.
ERROR: Error in the LIBNAME statement.
4 + LIBNAME sasdata2 'C:\DAG\SAS\Samples\
5 +


it seems to be taking the right value from the dataset files. I tried some changes in quoatations i have, to see if there is any issue. But didn't help.

Any suggestions??

Thanks,
Neel
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS variable is padded with blanks - you need to use TRIM against your variable. You may want consider building the command in a SAS variable and then use the SAS variable in your CALL EXECUTE rather than attempting to build the command string in the CALL - it may be easier to debug that way as well.

Scott Barry
SBBWorks, Inc.
data_null__
Jade | Level 19
To create LIBREFS from meta data it might be easier to use the LIBNAME function. You can also easily test the return code.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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