The IMPORT Procedure |
Procedure features: |
| ||||||||||||||
Other features: |
|
This example imports the following delimited external file and creates a temporary SAS data set named WORK.MYDATA:
Region&State&Month&Expenses&Revenue Southern&GA&JAN2001&2000&8000 Southern&GA&FEB2001&1200&6000 Southern&FL&FEB2001&8500&11000 Northern&NY&FEB2001&3000&4000 Northern&NY&MAR2001&6000&5000 Southern&FL&MAR2001&9800&13500 Northern&MA&MAR2001&1500&1000
Program |
proc import datafile="C:\My Documents\myfiles\delimiter.txt" out=mydata dbms=dlm replace; delimiter='&'; getnames=yes; run; options nodate ps=60 ls=80; proc print data=mydata; run;
SAS Log |
The SAS log displays information about the successful import. For this example, the IMPORT procedure generates a SAS DATA step, as shown in the partial log that follows.
/********************************************************************** 79 * PRODUCT: SAS 80 * VERSION: 9.00 81 * CREATOR: External File Interface 82 * DATE: 24JAN02 83 * DESC: Generated SAS DATA step code 84 * TEMPLATE SOURCE: (None Specified.) 85 ***********************************************************************/ 86 data MYDATA ; 87 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ 88 infile 'C:\My Documents\myfiles\delimiter.txt' delimiter = '&' MISSOVER 88 ! DSD lrecl=32767 firstobs=2 ; 89 informat Region $8. ; 90 informat State $2. ; 91 informat Month $7. ; 92 informat Expenses best32. ; 93 informat Revenue best32. ; 94 format Region $8. ; 95 format State $2. ; 96 format Month $7. ; 97 format Expenses best12. ; 98 format Revenue best12. ; 99 input 100 Region $ 101 State $ 102 Month $ 103 Expenses 104 Revenue 105 ; 106 if _ERROR_ then call symput('_EFIERR_',1); /* set ERROR detection 106! macro variable */ 107 run; NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 106:44 NOTE: The infile 'C:\My Documents\myfiles\delimiter.txt' is: Filename=C:\My Documents\myfiles\delimiter.txt, RECFM=V,LRECL=32767 NOTE: 7 records were read from the infile 'C:\My Documents\myfiles\delimiter.txt'. The minimum record length was 29. The maximum record length was 31. NOTE: The data set WORK.MYDATA has 7 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.04 seconds cpu time 0.05 seconds 7 rows created in MYDATA from C:\My Documents\myfiles\delimiter.txt. NOTE: .MYDATA was successfully created.
Output |
This output lists the output data set, MYDATA, created by the IMPORT procedure from the delimited external file.
The SAS System Obs Region State Month Expenses Revenue 1 Southern GA JAN2001 2000 8000 2 Southern GA FEB2001 1200 6000 3 Southern FL FEB2001 8500 11000 4 Northern NY FEB2001 3000 4000 5 Northern NY MAR2001 6000 5000 6 Southern FL MAR2001 9800 13500 7 Northern MA MAR2001 1500 1000
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.