• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

User defined libraries creations in SAS

User defined libraries creations:

 

Lib name statement:

It can be used to create user defined libraries. Libname statements global statement. It is stored outside the data set block and procedure block.

User can create 2 types of libraries

  1. Independent
  2. Dependent

 

Independent libraries:

If we store any data set in required library, it is available in that library only. This type of library is called independent library. It is temporary and permanent.

 

Dependent libraries:

If we store any data set in required library, its default stores in another library. This is called dependent library. It is temporary and permanent.

 

Independent library creation:

Temporary:

       Temporary library statement is created bt using libname statement. Libraries names you can give upto 8 characters

Syntax:

Libname<library name (or) reference> <engine>’<path>’;

At TekSlate, we offer resources that help you in learning various IT courses. We avail both written material and demo 
video tutorials. To gain in-depth knowledge and be on par with practical experience, then explore SAS Training PDF.

Engine:

It stores the data in SAS data set in different formats. These formats defaults takes based on versions(technologies)

Ex:

Lib name clinical ‘d;\gun’;

Data clinical . demo;

Input pid age color $ height;

Cards;

100 23 white 5.6

101 34 black  4.5

102  45 white 4.5

;

Proc print data =clinical demo .demo;

Run;

Note:

Difference between work to user defined library. Work is permanent but it stores data set temporary for SAS version. User defined temporary library, libraries also temporary and data sets also temp for SAS version.

 

Permanent: menu drive process:

Name – fill with library name -> engine(default)-> click on enable to start up -> browse(to specific pc path)-> click ok.

 

Dependent library creation:

Temporary:

Dependent library creation work on pc path

Ex:

Lib name Uma ‘d:\one’;

Libname Kumar(Uma);

Libname Kiran(Kumar);

/* or */

Libname Uma ’d:\one’;

Libname Kumar ’d:\one’;

Libname Kiran ’d:\one’;

Ex:

/* storage */

Data Uma .demo;

Input pid age;

Cards;

100 56

101 89

109 23

;

Proc print data= Uma. Demo;

Run;

 

Permanent:

If we want ot create a dependent libraries permanently we will click on enable to startup and assign same path for required libraries. Use with browse button.

 

Deletion of the libraries from SAS environment:

  1. Menu drive
  2. Coding

Note:

       Temporary libraries can be created by using menu drive and coding and the same way we can delete menu drive process and coding also.

Permanent library can be created by using menu drive. That’s way it can delete by menu drive only.

Syntax for library deletion:

      Libname<library reference or name> clear;

Capture

             

 

 

 

 

 

 

           

 

To read the data from one data set to another data set:

   Syntax:

Data<new data set name>;

Set<existed dataname>;

Run;

Ex:

Data emp;

Input eid salary sale;

Cards;

1234  2300  678

1245  4500  456

1256  8900  567

1456  3000  400

1890  4500  300

1235  7800  580

1267  5000  380

;

Data emp1;

Set emp;

Run;

Proc print  data =emp1;

Run;

 

Data manipulation:

      /* To store modification in same variable and new data set */

Data emp2;

Set emp;

Salary =salary +2000;

Run;

Proc print data =emp2;

Run;

/* To store modification in new variable and new data set */

Data emp3;

Set emp;

nSalary =salary +2000;

Run;

Proc print data =emp2;

Run;

/* To store modification in new variable and existed data set */

Data emp;

Set emp;

nSalary =salary +2000;

Run;

Proc print data =emp2;

Run;

If we want to do any work based on condition we will use conditional statement. Conditional statement are working based on operators.

For indepth knowledge on SAS, click on below

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Summary
Review Date
Reviewed Item
User defined libraries creations in SAS
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

1 Responses on User defined libraries creations in SAS"

  1. Nilesh Choudhary says:

    Hi,

    Just a little correction under the section mentioned below :
    Dependent library creation:
    Temporary:
    Dependent library creation work on pc path
    it generates a error when we are using a ‘ (single quote) to specify a location, I checked that once we use the ” (double quotes) for assigning it seems to be working perfectly fine.
    Additionally, thanks for shedding a light on the dependent and independent library allocation which shed some light on this concept.

    I would also like to know about the concept of de-assigning multiple libraries using a single statement. I tried using
    libname x y z clear;
    but it doesn’t works for me. Any suggestions or approaches.

    I would also like to suggest that we mention that the clear statement only deassigns the library and doesn’t delete’s the physical data (it would still take up the storage on the system). We should also mention the use of the Proc Datasets to delete the contents of the folder.

    But not sure how we could remove the folder one that we create in the d: using statements.

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.