Read File on SAS – Part 2

Another method to access to the file in your library using PROC IMPORT statement.

As usual, we will need to create a library statement to tell SAS where we keep our collection of datasets before we use PROC IMPORT to access the particular data file.

libname SAS “I:\SAS\Sample Folders”;

TITLE "Part II";

PROC IMPORT DATAFILE=“I:\SAS\Sample Folders\data.csv”

OUT=SAS.data

DBMS=CSV REPLACE;

GETNAMES=YES;

GUESSINGROWS=200;

RUN;

The code above indicates:

  • PROC IMPORT DATAFILE=“I:\SAS\Sample Folders\data.csv”
    • <to tell SAS where to get the particular dataset through the complete path and filename>
  • OUT=SAS.data
    • <to identify the SAS output through library name and datafile name>
    • <SAS = library name>
    • <data = datafile name>
  • DBMS=CSV REPLACE;
    • <DBMS = to specify type of data imported>
    • <replace = to overwrite an existing dataset, which is often used to ensure updated dataset overwrite the old & existing dataset>
  • GETNAMES=YES;
    • <to generate variable names from the data values>
    • <applicable only with PROC IMPORT>
  • GUESSINGROWS=200;
    • <to indicate no of rows to process in order to determine the datatype and length of each variable>
    • <applicable only for CSV/delimited data file>

 

Advertisements


Categories: SAS Learning

Tags: , , ,

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

%d bloggers like this: