Your SAS programs, embedded in web apps and elsewhere

Library with dynamic name cannot be created

Reply
Occasional Contributor
Posts: 8

Library with dynamic name cannot be created

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.

Contributor
Posts: 42

Library with dynamic name cannot be created

Posted in reply to kuro_kuro

Can you send the log from each STP?

Regular Contributor
Regular Contributor
Posts: 166

Library with dynamic name cannot be created

Posted in reply to kuro_kuro

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

Respected Advisor
Posts: 4,173

Re: Library with dynamic name cannot be created

Posted in reply to kuro_kuro

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

Occasional Contributor
Posts: 13

Library with dynamic name cannot be created

Posted in reply to kuro_kuro

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

Super User
Super User
Posts: 7,050

Library with dynamic name cannot be created

Posted in reply to kuro_kuro

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;


Ask a Question
Discussion stats
  • 5 replies
  • 320 views
  • 0 likes
  • 6 in conversation