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
Remove the 5. from the input statement and it reads in fine.
What do you need the 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.
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.
@ballardw, Its not a list input, lists dont generally use any pointer control. var $ 1-5 is column method.
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 ;
@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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.