Reading Data

Other topics

Read text file with comma delimiter

DATA table-name;
    INFILE "file-path/file-name.csv" dsd;
    INPUT Name $ City $ Age;
RUN;

Read data from excel file

PROC IMPORT DATAFILE = "file-path/file-name.xlsx" OUT=data_set DBMS=XLSX REPLACE;

PROC IMPORT for Excel, importing a specific sheet

There will be times where you only want to import a specific sheet from an excel file with multiple sheets. To do that, we'll use "SHEET=".

PROC IMPORT 
    OUT= YourNewTable
    DATAFILE= "myfolder/excelfilename.xlsx" 
    DBMS=xlsx 
    REPLACE;
    SHEET="Sheet1";
    GETNAMES=YES;
RUN;

Also take note of the ability to specify whether or not the top row imported contains column names or not (GETNAMES=YES (or NO).

Contributors

Topic Id: 7989

Example Ids: 25827,25857,29119

This site is not affiliated with any of the contributors.