You are on page 1of 9

SAS Tips

Xiaowei Zhan
April 5, 2007
Content
 Import data
 Prettier output
Import Data
 From Excel file

Doing your regression homework would be simpler,


since the data is provided on textbook website.
Import Data
 Compare:
1 DATA homework;
INPUT y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 @@;
LINES;
18.9 350 165 260 8 2.56 4 3 200.3 69.9 3910 1
……
2 DATA homework;
INFILE “abc.txt”;
INPUT y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11;

3 PROC IMPORT DATAFILE=‘abc.xls’ OUT=homework REPLACE;


Import Data
 From CSV (Comma Separated Values) file
Sample CSV file: 1,2,1,4,2
3,4,1,5,2
…..

Data dataset;
INFILE ‘filename' DLM=‘,’ DSD MISSOVER FIRSTOBS=2;
INPUT y x1 x2 x3 x4;
Prettier output
 Use SAS ODS (Output Delivery System)

ODS filetype FILE=“filename”;


solve your homework…
ODS filetype CLOSE;
Prettier output
 Example
PROC IMPORT datafile=“data-table-B14.XLS" OUT=abc REPLACE;
ODS HTML FILE="body.htm"
PROC PRINT data=abc;
PROC REG;
MODEL y=x1 x2;
RUN;
ODS HTML CLOSE;
Prettier output
 Other types of output include:
PDF, RTF…
HTML PDF RTF
ODS HTML FILE=“out.html”; ODS PDF FILE=“out.pdf”; ODS RTF FILE=“out.rtf”;
Your code… Your code… Your code…
ODS HTML CLOSE; ODS PDF CLOSE; ODS RTF CLOSE;
Further Info?
 The Little SAS Book: A Primer
by Lora D. Delwiche ,
Susan J. Slaughter

You might also like