BookmarkSubscribeRSS Feed
Kushal_1991
Calcite | Level 5

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

6 REPLIES 6
Reeza
Super User

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

What do you need the 5.?

Kushal_1991
Calcite | Level 5

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

ballardw
Super User

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.

Kushal_1991
Calcite | Level 5

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

ballardw
Super User

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 ;


Kushal_1991
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 640 views
  • 0 likes
  • 3 in conversation