I am trying to understand how Call Execute works.. I tried a very simple program which creates a library reference
Below is sample code..
call execute('LIBNAME sasdata2 ''C:\DAG\SAS\Samples\'';'
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
call execute('LIBNAME sasdata2 '''||folderName||''';'
I get the following -
NOTE: CALL EXECUTE generated line.
1 + LIBNAME sasdata2 'C:\DAG\SAS\Samples\
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\
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.
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.