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-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
  • 6 replies
  • 899 views
  • 1 like
  • 6 in conversation