0% found this document useful (0 votes)
107 views3 pages

SAS-Importing A File

This document discusses various methods for importing data into SAS, including importing an Excel file, storing SAS data sets in alternate locations, entering internal data, and reading raw data files using list, column, and mixed input methods. The key points covered are: 1) The PROC IMPORT statement is used to import an Excel file into a SAS data set. 2) The LIBNAME and OPTIONS statements allow storing SAS data sets in locations other than the WORK library. 3) Internal and raw external data can be read into SAS using the DATA step and INPUT statement with list, column, or mixed formats. 4) Different file formats like text files with rows or columns of data values can be read using appropriate

Uploaded by

prabhuiipm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views3 pages

SAS-Importing A File

This document discusses various methods for importing data into SAS, including importing an Excel file, storing SAS data sets in alternate locations, entering internal data, and reading raw data files using list, column, and mixed input methods. The key points covered are: 1) The PROC IMPORT statement is used to import an Excel file into a SAS data set. 2) The LIBNAME and OPTIONS statements allow storing SAS data sets in locations other than the WORK library. 3) Internal and raw external data can be read into SAS using the DATA step and INPUT statement with list, column, or mixed formats. 4) Different file formats like text files with rows or columns of data values can be read using appropriate

Uploaded by

prabhuiipm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

/* IMPORTING AN EXCEL FILE INTO SAS*/

proc import
datafile = "C:\Documents and
Settings\Prabu\Desktop\ICMR\CBRE\economy.xls"
out = economy
dbms = excel;
run;

/* STORING A DEFAULT FILE IN DIFF LOCATION( OTHER THAN WORK)*/

libname user "C:\Documents and Settings\Prabu\Desktop\ICMR\CBRE";


data honey;
set sashelp.class;
run;

STORING THE FILE IN USER

options reny "C:\Documents and Settings\Prabu\Desktop\ICMR\CBRE";


data reny;
set sashelp.class;
run;

ENTERING DATA( Internal Data) INTO SAS:

data russia;
run;
data russia;
input state $ population airports;
datalines;
larco 10000 3
texico 5000 6
;
run;

READING A RAW DATA SEPERATED BY SPACES

LIST INPUT METHOD:

data toads;
run;
data toads;
infile 'C:\Documents and Settings\Prabu\Desktop\ICMR\CBRE\toadjump.txt';
input toadname $ weight jump1 jump2 jump3;
run;
proc print data=toads;
run;
TEXT FILE

lucky 2.3 1.9 . 3.0


spot 4.6 2.5 3.1 .5
tubs 7.1 . . 3.8

READING RAW DATA ARRANGED IN COLUMNS:

COLUMN INPUT METHOD:

data sales;
run;

data sales;
infile 'C:\Documents and
Settings\Prabu\Desktop\ICMR\CBRE\onionring.txt';
input visitingteam $ 1-16 concessionsales 20-22 bleachersales 24-25
ourhits 26-27 theirhits 28-30 ourruns 31-32 theirruns 33-34;
run;
proc print data=sales;
run;

INPUT METHODS

MIXED FORMAT

data nationalparks;
infile "C:\Documents and Settings\Prabu\Desktop\ICMR\SAS\Class
notes\natpark.txt";
input parkname $ 1-22 state $ year @40 acre comma9.;
run;
proc print data=nationalparks;
run;

** @40 ACRE COMMA9 : STARTS READING THE ACRE VARIAVBLE AFTER 40TH
COLUMN.

USING IMPORT STATEMENT:

Using DLM:

data chitra;
infile "C:\Documents and
Settings\Prabu\Desktop\ICMR\SAS\Infile\chitra.txt" DLM = ",";
input subject $ sixth seventh eighth nineth;
run;
proc print data = chitra;
run;

You might also like