SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Unable to import tab file using infile statement?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Unable to import tab file using infile statement?

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     


Accepted Solutions
Solution
‎04-02-2015 07:09 AM
Respected Advisor
Posts: 3,799

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

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


All Replies
Trusted Advisor
Posts: 3,212

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

DLM= http://support.sas.com/techsup/technote/ts673.pdf

---->-- ja karman --<-----
Super User
Posts: 7,768

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

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

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 435

Re: Unable to import tab file using infile statement?

Posted in reply to KurtBremser

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

Super User
Posts: 7,768

Re: Unable to import tab file using infile statement?

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)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 89

Re: Unable to import tab file using infile statement?

Posted in reply to KurtBremser

Thanks.I have attached zip file too.

Solution
‎04-02-2015 07:09 AM
Respected Advisor
Posts: 3,799

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

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.;
Frequent Contributor
Posts: 89

Re: Unable to import tab file using infile statement?

Posted in reply to data_null__

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

Attachment
Attachment
Respected Advisor
Posts: 3,799

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

There is nothing useful in your attached log.

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

Respected Advisor
Posts: 3,799

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

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.

Super User
Posts: 10,023

Re: Unable to import tab file using infile statement?

Posted in reply to venkatnaveen

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

Respected Advisor
Posts: 3,799

Re: Unable to import tab file using infile statement?

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.

Frequent Contributor
Posts: 89

Re: Unable to import tab file using infile statement?

Posted in reply to data_null__

Thanks to all.

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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