English 中文(简体)
SAS - Data Sets
  • 时间:2024-11-03

SAS - Data Sets


Previous Page Next Page  

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 pke 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 pbrary.

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 pst of names of all the built-in Data Sets available.

data_sets_1_explore

Lets scroll down to locate a Data Set named CARS.Double cpcking 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.

data_sets_2_CARS

We can scroll to the right using the scroll bar in the bottom to explore all the columns and theirs values in the table.

data_sets_3_CARS_explore

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.

data_sets_4_1_loacl_files_to_server

Next we use the above file in a SAS program by importing it. To do this we use the option Tasks -> Utipties -> Import data as shown below. Double cpck the Import Data button which opens up the window in the right to choose the file for the Data Set.

Next Cpck on the Select Files button under the import data program in the right pane. The following are the pst of the file types which can be imported.

data_sets_5_import_files

We choose the "employee.txt" file stored in the local system and get the file imported as shown below.

data_sets_4_2_import_utipty

View the imported data

We can view the imported data by running the default import code generated using the Run option

data_sets_6_view_imported_data

We can import any other file types using the same approach as above and use it in various SAS programs.

Advertisements