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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1265 views
  • 0 likes
  • 3 in conversation