BookmarkSubscribeRSS Feed
zhangyu027
Calcite | Level 5

May I ask how to assign a permanent lib to data? Thanks. 

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS Communities 🙂

 

What version of SAS do you use?

PeterClemmensen
Tourmaline | Level 20

If you are on 9.x, then click the 'New Library' Button at the top ribbon to get the below window. Then choose the 'Enable at startup' box and fill in the rest accordingly.

 

 

Capture.PNG

Nasya
Obsidian | Level 7

Hi,

 

The following is an example of the LIBNAME statement and SET statement that is used with a DATA step:

libname pdata 'your-data-library';  
data ds1; 
   set pdata;
by ID;
run; proc print data = ds1; run;

Here, PDATA,DS1 and ID are used generically.

Hope this helps.

 

Regards,

Nasya

SharonZS
Obsidian | Level 7

Hi,

In order to create and save a permanent SAS data file in a library you'll want to use the following syntax:

 

libname pdata 'your-data-library';  /*Path for where you want to store data set/where your data is located*/

 

data pdata.ds1;       /* New permanent SAS data file stored in pdata library. */

    set   ds1;            /* temporary SAS data file*/
run;

Kurt_Bremser
Super User

You define the library reference with a libname statement. In order for a library to be "permanent" (available for use everytime a new SAS session starts), you need to have it somewhere in the structures that could be called "part of the autoexec process". Depending on your SAS setup, this could be

  • a statement in one of the autoexec.sas files that are called when the SAS session starts. A BI Server has multiple such files with inheritance.
  • a definition in SAS metadata (in a BI Server environment).
  • a statement executed whenever you connect to a SAS server from Enterprise Guide.
  • a statement executed whenever code is sent to the SAS server.
  • a statement in an "Autoexec" process flow in a SAS Enterprise Guide project file.

(this list is not complete by far)

andreas_lds
Jade | Level 19
@Nasya: two errors in your code:
"Set psdata" references the dataset psdata in the work library.
"data = ds1" also processes work.ds1.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1221 views
  • 1 like
  • 6 in conversation