How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

Reply
New Contributor
Posts: 3

How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

How do I read dilimeters with control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

My input file has control A as dilimeter and I tried using '01'x but SAS doesnt recognise the option.

  

Any help would be very much appreciated.

   

THanks

Sutritha

PROC Star
Posts: 7,492

Re: How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

Are you sure that is the delimiter and/or that you specified it correctly?  The following worked for me:

data _null_;

file "c:\testit";

put "a" @;

put "01"x @;

put "b";

put "cc" @;

put "01"x @;

put "d" @;

put "01"x @;

put "e";

run;

data want;

  infile "c:\testit" dsd delimiter="01"x truncover;

  input (var1-var3) ($);

run;

Respected Advisor
Posts: 4,934

Re: How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

Yes, SAS statement INFILE "myFile.txt' dlm="01"x; works as expected. At least on Windows. Can you post some code. The problem must be somewhere else.

PG

PG
New Contributor
Posts: 3

Re: How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

Thank you so much for the reply.

My input file is in UNIX.

When I open my file using VI editor, I get this:

HELLO^AHELLO^A

I am using this code.

infile inpfile dlm="01"x dsd missover truncover;

input name1 $5.

     name2 $5.

;

Respected Advisor
Posts: 4,934

Re: How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

try

infile inpfile dlm="01"x dsd missover truncover;

length name1 name2 $5;

input name1 name2;

PG

PG
PROC Star
Posts: 7,492

Re: How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

I agree that PGStats may have identified the problem, but why are you including both missover and truncover options?

New Contributor
Posts: 3

Re: How do I read control characters in SAS using INFILE statement? I am specifically interested in reading ^A.

Thanks guys. The length statement solves the problem.

Ask a Question
Discussion stats
  • 6 replies
  • 648 views
  • 0 likes
  • 3 in conversation