Features: |
|
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 ;
/*** Specify the input file.***/ /*** Identify the output SAS data set.***/ /*** Specify the input file is a delimited file.***/ /*** Replace the data set if it exists.***/ /*** Specify delimiter as an & (ampersand).***/ /*** Generate variable names from first row of data.***/ options nodate ps=60 ls=80; proc import datafile="C:\My Documents\myfiles\delimiter.txt" dbms=dlm out=mydata replace; delimiter='&'; getnames=yes; run; proc print data=mydata; run;
1 options nodate ps=60 ls=80; proc import datafile="C:\My 1 ! Documents\myfiles\delimiter.txt" dbms=dlm out=mydata replace; delimiter='&' 1 ! delimiter='&'; getnames=yes;run; 2 /********************************************************************** 3 * PRODUCT: SAS 4 * VERSION: 9.3 5 * CREATOR: External File Interface 6 * DATE: 31JAN11 7 * DESC: Generated SAS Datastep Code 8 * TEMPLATE SOURCE: (None Specified.) 9 ***********************************************************************/ 10 data WORK.MYDATA ; 11 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ 12 infile 'C:\My Documents\myfiles\delimiter.txt' delimiter = '&' MISSOVER 12 ! DSD lrecl=32767 firstobs=2 ; 13 informat Region $8. ; 14 informat State $2. ; 15 informat Month MONYY7. ; 16 informat Expenses best32. ; 17 informat Revenue best32. ; 18 format Region $8. ; 19 format State $2. ; 20 format Month MONYY7. ; 21 format Expenses best12. ; 22 format Revenue best12. ; 23 input 24 Region $ 25 State $ 26 Month 27 Expenses 28 Revenue 29 ; 30 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection 30 ! macro variable */ 31 run; NOTE: The infile 'C:\My Documents\myfiles\delimiter.txt' is: Filename=C:\My Documents\myfiles\delimiter.txt, RECFM=V,LRECL=32767,File Size (bytes)=254, Last Modified=31Jan2011:11:44:29, Create Time=31Jan2011:11:44:29 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 30. NOTE: The data set WORK.MYDATA has 7 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.06 seconds cpu time 0.03 seconds 7 rows created in WORK.MYDATA from C:\My Documents\myfiles\delimiter.txt. NOTE: WORK.MYDATA data set was successfully created.