Hi I am unable to import tab file
Here is the code
DATA Moss2013;
LENGTH Address $ 24 ;
INFORMAT Date YYMMDD10. Time $7. ;
FORMAT Date YYMMDD10. Time $7. ;
INFILE 'C:\nav\2013_Satisfaction_Survey_Moss.txt'
LRECL=32767 DLM='09'x MISSOVER DSD firstobs=2;
INPUT Date: YYMMDD10. Time : $7.
Interviewer :$9. Age Gender :$3. Address: $24. FirstTime :$6. ComeAgain :$5. WhyNot $11. Sat1 :$6. Sat2:$6. Sat3:6. Sat4:$6.
Sat5 :$6. Sat6 :$6. Sat7 :$6; Sat8 :6. Comments :$19.;
;
RUN;
The data is like given below:
Date Time Interviewer Age Gender Address FirstTime ComeAgain WhyNot Sat1 Sat2 Sat3 Sat4 Sat5 Sat6 Sat7 Sat8 Comments
2013-10-09 12:15 Moss 65 M Stanardsville, VA NO YES 3 3 3 3 3 3 4 4 no parking
2013-10-12 12:38 Moss 28 F Crozet, VA NO YES N/A 1 3 4 4 3 N/A 3
2013-10-07 Moss 49 F Thurston, VA YES DK 4 3 3 4 3 N/A N/A 3
You are missing a colon format modified for variable WhyNot $11. and you have simicolon after Sat7 :$6; causing the next part of the statement to be "180 used out of order."
DLM= http://support.sas.com/techsup/technote/ts673.pdf
The data you posted does not contain any tabs/hex 09's. Could you attach a zip of the original file?
Have you already looked at your infile with a hex viewing tool to make sure that it has the expected structure?
And what happened when you tried the import (log, resulting dataset)?
Could you please tell me how hex 09's file look like? Any sample record?
A hex viewing tool shows you the tab as 09 (00001001 binary). That's all about it.
When read into a text editor, the tabs are expanded according to the tab setting of the editor (or operating system).
If you want to create a sample, type a tab in the windows editor and save as .txt. Then view it with notepad++ (Plugins - Hex Editor - View in HEX)
Thanks.I have attached zip file too.
You are missing a colon format modified for variable WhyNot $11. and you have simicolon after Sat7 :$6; causing the next part of the statement to be "180 used out of order."
Thanks Data_null_,
But I am getting some missing records.I have modified code.
DATA Moss2013;
LENGTH Address $ 24 Comments $ 50 ;
INFORMAT Date YYMMDD10. Time $7. ;
FORMAT Date YYMMDD10. Time $7. ;
INFILE 'C:\nav\2013_Satisfaction_Survey_Moss.tab'
LRECL=32767 DLM='09'x truncover DSD firstobs=2;
INPUT Date: YYMMDD10. Time : $7.
Interviewer :$9. Age Gender :$3. Address: $24. FirstTime :$6. ComeAgain :$5. WhyNot: $11. Sat1 :$6. Sat2:$6. Sat3:6. Sat4:$6.
Sat5 :$6. Sat6 :$6. Sat7 :$6 Sat8 :$6. Comments :$50.;
;
RUN;
proc printto log='C:\nav\errors.log';
run;
proc printto;
run;
Here with I am attching the errors file too
There is nothing useful in your attached log.
When I read the file I get some invalid data for Sat3:6.
You are missing the dot on $6 informat for Sat7 :$6.
The 6 with no dot means COLUMN 6 moving the pointer back to column 6.
You can change it into white blanks by expandtabs , and make blank as delimiter.
INFILE 'C:\nav\2013_Satisfaction_Survey_Moss.tab'
LRECL=32767 expandtabs DLM=' ' truncover DSD firstobs=2;
Xia Keshan
That's not the problem the problems are on the INPUT statement. Missing syntax elements.
Plus and more importantly changing the delimiter to blank will cause all kinds of problems as missing values are not "marked" and some fields have embedded blanks, causing more problems that it can fix.
Thanks to all.
I made the corrections as per ur suggestions and got correct answer.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.