DATA STEP problem

Reply
Occasional Contributor
Posts: 7

DATA STEP problem

Contents of a.txt

22

333

4444

55555

But when i run this code :

data numbers;

infile ’c:\a.txt’;

input var 5.;

/* list */ ;

run;

the data in numbers.sas is saved as :

var

  

var1

   333

55555

But when i use the list the input buffer is somewhat like this :

RULE:    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----

2             333 3

4             55555 5

Please explain

Super User
Posts: 17,905

Re: DATA STEP problem

Remove the 5. from the input statement and it reads in fine.

What do you need the 5.?

Occasional Contributor
Posts: 7

Re: DATA STEP problem

@Reeza I know without using 5. it will work fine......i just want to see how the buffer is reading the data. Actually I want to find out what is the default method of sas  during column input when there is less no. of columns in an observation than specified in the input statement.

Super User
Posts: 10,535

Re: DATA STEP problem

You used list input which defaults to using spaces as delimiters between variables.

To read the first 5 characters as a single text value you want

input var $ 1-5;

The $ says to read it as character and the 1-5 says to read everything in those 5 columns.

Occasional Contributor
Posts: 7

Re: DATA STEP problem

@ballardw, Its not a list input, lists dont generally use any pointer control. var $ 1-5 is column method.

Super User
Posts: 10,535

Re: DATA STEP problem

I mispoke, list and formatted input are mixed often enough I don't differentiate between them all the time. Your input is Formatted input; the period with the 5 makes it a numeric format with no decimals. You have not set a line pointer which would be indicated with either @n or +n.

See what you get with

input @2 var ;

then

input @5 var ;


Occasional Contributor
Posts: 7

Re: DATA STEP problem

@Reeza I know without using 5. it will work fine......i just want to see how the buffer is reading the data. Actually I want to find out what is the default method of sas  during column input when there is less no. of columns in an observation than specified in the input statement.

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