Creating Permanent SAS Data set from Raw file

SAS recognizes data only in the form of SAS data set. Hence, if your data is in any other format, it needs to be produced into a SAS data set.

First lets create a folder in “\SAS University Edition\myfolders” in Windows environment. SAS University Edition folder is located in the path you had suggested while installing the software. In “myfolders”, I created a new folder and renamed it as “mine”. So, the path for mine is “\SAS University Edition\myfolders\mine”. I created this folder to organize my work.

library_sas

Check this folder in SAS window.

library_sas

Create a Library

Now we shall create a new library which will be used to store our  new SAS data set.

program_sas

Here, we used LIBNAME statement created a new library called “mine” and set the location of the library as the location of mine folder in myfolders. To get the location/path of the folder – Right click on the folder and select properties

library_sas

 

Create SAS Data set

To create a SAS data set from an existing file in another format, we need to upload the data set into SAS environment from Windows environment. For that in SAS window, select mine and click on Upload button library_sas and click on Choose files. Select all the file(s) that are required and click on open.

Here, we can see three data sets uploaded in mine folder.

library_sas

Import Procedure

The data set that we are going to use is diamonds.csv. We use IMPORT Procedure to import the data set. The OUT Option specifies a name for SAS data set(Notice mine.diamonds – library name is specified to save the data set permanently). The DATAFILE Statement specifies the location/path of the uploaded file. DBMS Statement indicates the type of uploaded file. GETNAMES Statement tells SAS whether the first row of the data values is to be considered as variable names or not(Yes – if to be considered as variable names).

program_sas

 

Look at the Diamonds data set in Mine library.

program_sas

Data Inspection

The Diamonds data set has 53940 observations and 10 variables. Lets check first ten and last ten observations.

results_sas

 

Great! We successfully created a permanent SAS data set.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s