SAS - Data Sets
The data that is available to a SAS program for analysis is referred as a SAS Data Set. It is created using the DATA step. SAS can read a variety of files as its data sources like CSV, Excel, Access, SPSS and also raw data. It also has many in-built data sources available for use. The Data Sets are called temporary Data Set if they are used by the SAS program and then discarded after the session is run. But if it is stored permanently for future use then it is called a permanent Data set. All permanent Data Sets are stored under a specific library. The SAS Data set is stored in form of rows and columns and also referred as SAS Data table. Below we see the examples of permanent Data sets which are in-built as well as red from external sources.
SAS Built-In Data Sets
These Data Sets are already available in the installed SAS software. They can be explored and used in formulating sample expressions for data analysis. To explore these data sets go to Libraries -> My Libraries -> SASHELP. On expanding it we see the list of names of all the built-in Data Sets available.
Lets scroll down to locate a Data Set named CARS. Double clicking on this Data Set opens it in the right window pane where we can explore it further. We can also minimize the left pane by using the maximize view button under the right pane.
We can scroll to the right using the scroll bar in the bottom to explore all the columns and theirs values in the table.
Importing External Data Sets
We can export our own files as Data sets by using the import feature available in SAS Studio. But these files must be available in the SAS server folders. So we have to upload the source data files to SAS folder by using the upload option under the Server Files and Folders.
Next we use the above file in a SAS program by importing it. To do this we use the option Tasks -> Utilities -> Import data as shown below. Double click the Import Data button which opens up the window in the right to choose the file for the Data Set.
Next Click on the Select Files button under the import data program in the right pane. The following are the list of the file types which can be imported.
We choose the "employee.txt" file stored in the local system and get the file imported as shown below.
View the imported data
We can view the imported data by running the default import code generated using the Run option
We can import any other file types using the same approach as above and use it in various SAS programs.