BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
venkatnaveen
Obsidian | Level 7

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     

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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."

INPUT Date: YYMMDD10. Time : $7.
  Interviewer :
$9. Age Gender :$3. Address: $24. FirstTime :$6. ComeAgain :$5. WhyNot :$11.
   (Sat1-Sat8)(:
$6.)  Comments :$19.;

View solution in original post

12 REPLIES 12
Kurt_Bremser
Super User

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)?

Babloo
Rhodochrosite | Level 12

Could you please tell me how hex 09's file look like? Any sample record?

Kurt_Bremser
Super User

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)

venkatnaveen
Obsidian | Level 7

Thanks.I have attached zip file too.

data_null__
Jade | Level 19

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."

INPUT Date: YYMMDD10. Time : $7.
  Interviewer :
$9. Age Gender :$3. Address: $24. FirstTime :$6. ComeAgain :$5. WhyNot :$11.
   (Sat1-Sat8)(:
$6.)  Comments :$19.;
venkatnaveen
Obsidian | Level 7

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

data_null__
Jade | Level 19

There is nothing useful in your attached log.

When I read the file I get some invalid data for Sat3:6.

data_null__
Jade | Level 19

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.

Ksharp
Super User

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

data_null__
Jade | Level 19

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.

venkatnaveen
Obsidian | Level 7

Thanks to all.

I made the corrections as per ur suggestions and got correct answer.

SAS Innovate 2025: Register Now

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!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 12 replies
  • 2449 views
  • 10 likes
  • 6 in conversation