DATA Step, Macro, Functions and more

How to link SAS file from defined path?

Reply
Super Contributor
Posts: 319

How to link SAS file from defined path?

[ Edited ]

Hello:

 

I have a 'Template' file saved in the ZK file.  Everytime, I need to open libname then use data step to input into work library.   Is there a way to link to the 'Template' file and send it to the work library directly?  Thanks.

 

libname ZK "\\abb.org\ybz12003\Test";

data template; set ZK.template; run;

Super User
Posts: 7,854

Re: How to link SAS file from defined path?

You can use your dataset from USER directly. No need to copy it to WORK.

 

Since WORK is a dynamic location that is created when a SAS process starts and deleted when the SAS process terminates, you cannot create anything permanent in it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 319

Re: How to link SAS file from defined path?

Sorry, I probaby should not use the 'USER'.   Below is my acturaly code.

 

1 data zk.itemplate;

2 set template;

ERROR: File WORK.TEMPLATE.DATA does not exist.

3 run;

ERROR: Libref ZK is not assigned.

NOTE: The SAS System stopped processing this step because of errors.

 

Super User
Posts: 7,854

Re: How to link SAS file from defined path?

That tells you two things

- library zk is not assigned

- there is no dataset template in work

 

If template exists anywhere, use the correct library for it. If the library is not yet assigned, assign one.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 319

Re: How to link SAS file from defined path?

That is what I am asking.   I need to assign one libname and run data step to assign 'Template' file to work library.   I am looking for if I could combine below two steps into one step.  Thanks.

 

libname ZK "\\abb.org\ybz12003\Test";

data template; set ZK.template; run;

Trusted Advisor
Posts: 1,584

Re: How to link SAS file from defined path?

Does your code run as is? Yes  means you have the template dataset in your WORK library.

 

If you want to save the template in your own library, so that you do not run same code each time you start SAS,

 

than define your own library and save it there:

 

libname ZK "\\abb.org\ybz12003\Test";
libname user "...your path ...";  /* you can change name from USER to any other name */

data user.template; 
  set ZK.template; 
run;

Next sas session use as:

 

libname user "...same path as origin ...";
data want;
  set user.template;
   ...any code ...
run;

 

Ask a Question
Discussion stats
  • 5 replies
  • 76 views
  • 0 likes
  • 3 in conversation