x
Get Certified as a SAS Base Programmer
28
Training Modules |
200+
Exam Questions |
100%
Instructor Support |
100%
Pass Guarantee |
|
Lesson 3: Importing data from external sources
IMPORTANT! This tutorial is updated on March 9, 2017. See the latest training on importing Excel spreadsheet into SAS. This lesson will explain how to import data from Excel, CSV and Text files.
1. EXCEL Example Below is the excel file that I am going to read into SAS: PROC IMPORT DATAFILE= "C:\test.xls" OUT=SASCrunch DBMS=Excel REPLACE; ** Optional **; GETNAMES=Yes; SHEET = "Sheet 1"; RUN; Let’s break down the codes above:
(1) DATAFILE indicates the directory and file name of the external source. (2) OUT = SASCrunch creates a dataset storing the output. This dataset is named 'SASCrunch'. (3) DBMS indicates the file type of the imported file. In this example, it is an Excel file. (4) REPLACE tells SAS to overwrite the file if a file with the exact same name already exists. (5) GETNAMES tells SAS to read the first row of the Excel spreadsheet as the variable names. Contents of the variables will be read from row 2. (6) SHEET identifies which Excel spreadsheet should be read in. You do not need to memorize the codes. Copy them from our website whenever you need to import the data from Excel.
DONE! You have learned to import data from Excel. Note:
What you can do if you don’t have the license is to save the excel file into a csv file and then import the csv file into SAS. This will be explained in the next section.
|
|