BookmarkSubscribeRSS Feed
kuro_kuro
Calcite | Level 5

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.

5 REPLIES 5
jcbell
Obsidian | Level 7

Can you send the log from each STP?

NN
Quartz | Level 8 NN
Quartz | Level 8

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

Patrick
Opal | Level 21

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

Maheshvaran
Calcite | Level 5

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

Tom
Super User Tom
Super User

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;


sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 1108 views
  • 0 likes
  • 6 in conversation