Creating and deleting a library

  • Date September 13, 2019
  • Written by Katsiaryna Ramanovich
  • Category Curl

This guide shows how to create and delete library using SAS9API and CURL.

Objectives:

  • How to create (pre-assigned) library with a Post-request and CURL.
  • How to verify the result with Get-request and CURL.
  • How to delete (pre-assigned) library with Delete-request and CURL.

 

Introduction

There are two types of libraries: permanent (pre-assigned) and temporary. SAS permanent (pre-assigned) libraries are saved until you delete them. The permanent (pre-assigned) library is available for processing in the following SAS sessions. The SAS temporary library exists only for the current SAS session.

Step 1 – Use this parameters.

To create a permanent (pre-assigned) library, you can use this table:

Parameter Description
0 ServerName Your server name
1 LibraryName Created library name, as will be used in LIBNAME statement
2 RepositoryName Repository name
3 Engine Libname engine
4 DisplayName Library display name
5 Path Library data path
6 Location Folder to place metadata object

 

Step 2 – Make a POST-request.

Make a POST-request with your parameters:

Our CURL request looks like this:

Status 200 – success without errors. All the parameters are the same as in our request:

The SAS9API permanent (pre-assigned) library was created successfully.

Step 3 – Verification.

For verification, you can send a request to the server to get all the parameters of the new library or display a list of all libraries.
In the first case, we use GET-request “Get library information for workspace server by library name”.

Our CURL request looks like this:

The response is the information about the created library SAS9API:

The second way: get the list of libraries for workspace server:

We to run the following CURL command:

Response is a complete list of our libraries including SAS9API:

 

Step 4 – Deleting library.

If you want to remove your library, you should know the libraries name (SAS9API) and send a DELETE request:

We to run the following CURL command:

Response is:

Status 200 – success without errors.

Step 5 – Check if the library was deleted.

For this we send a GET-request to show the parameters of the library by name (Step 3).
In the response, the status 500 is written – an internal server error and the reason for the error is described: “The library was not found».

The library with the name SAS9API does not exist.

Conclusion

This example showed how to create and delete a permanent (pre-assigned) library and how to check it using SAS9API and CURL.

For this and other examples, see www.sas9api.io/examples.
[ninja_form id=1]