Sunday, July 27, 2008

Ways to import excel and dat files into SAS

1. SAS Version 9 offers the Excel libname engine:
LIBNAME libref ;
LIBNAME libref CLEAR;

The CLEAR option closes the workbook connection when finished so the workbook can be opened or moved.

2
. Import dat file into SAS:

DATA ussd95;
INFILE 'C:\...\ussd95.dat' termstr=crlf;
INPUT V1 $ 1-2 V2 $ 5-9 V3 $ 11-45 v4 47-54 v5 56-63 v6 65-72 v7 $ 74-93;
leaid=cats(of v1 v2); /*
Concatenating string variables; leading or trailing blanks*/

rename v3=name;
RUN;


0 comments: