I would like to ask regarding creating library by using stored process. I have 2 stored process that will 1 library (physical).
In the first stored process I created the library and its name based on username;because I have severals users that will use it. And the second stored process is access its library. So, every users has their own library. When I create library in the first stored process is successfull; but when I access it by using second stored process, it said the library is not exist. Here are my code:
Test1.sas: *create libary
%stpbegin;
%global month_from month_to _METAUSER;
libname test BASE "<my libref location>";
DATA _NULL_;
call symput("table_name",cats("Lib_","&_METAUSER"));
run;
DATA test.&table_name; *(the problem)
month_from="&month_from";
month_to="&month_to";
run;
%stpend;
Test2.sas:*access library
%stpbegin;
%global month_from month_to _METAUSER;
libname test BASE "<my libref location>";
DATA _NULL_;
call symput("table_name",cats("Lib_","&_METAUSER"));
run;
DATA _NULL_;
set test.&table_name; *(the problem)
call symput("month_from"),month_from);
call symput("month_to"),month_to);
run;
%stpend;
Hopefully, anyone can help me or suggest another way so the 2 stored process can communicate by its own user. Thank You.
Can you send the log from each STP?
Hi,
Just a few questions.. is your dataset getting created in the libref when you execute stp1?.
if yes, then does the same code execute properly if run through STP2...
if both these are working then either ur actual code or log will be required for others to check
Are you running your sp on a stored process server and are you creating and maintaining a session so that all your stored processes use the same environment? If not then this would explain the issue you're having.
Here the doco (page 33 ff):
http://support.sas.com/documentation/cdl/en/stpug/61271/PDF/default/stpug.pdf
Hi Kuro-Kuro,
Just a though, i have not used stored processes yet but wont the Macro reference here need two periods? as such:
DATA test..&table_name; *(the problem)
This is just something i know has to be done in normal code because u reference a library before the data set.
Kind Regards,
Maheshvaran
What is the problem that you are having? Did you get any error messages in the logs?
It is not the library name that is dynamic in your example, but that dataset name.
Also note that you do not need to use a dataset to concatenate macro variables.
%let table_name=Lib_&_METAUSER;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.