Hello, All
Suppose I input just one variable Var:
Data Test;
Informat Var $10.;
input Var;
Cards;
abcdefg
ab cdefg
;
I got the following result:
abcdefg
ab
It seems to me that the informat does not work for records 2 in which only the first two characters were recognized because the third character is a blank.
How to let SAS know that the blank character is also part of the data?
You can also use a helpful informat $varying.Such as:
data temp;
infile datalines length=len;
input var $varying200. len;
datalines;
............
Ksharp
Hi:
You can use:
input @001 var $char10.;
as long as the data lines start in cc01.
Thank you all for helping me.
By the way: what is the difference between input @1 and input @001 ?
nope
No difference. They might have used the extra zeros to just make the code look more consistent.
INPUT
@001 var1 $120.
@121 var2 5.
...
;
You can also add & after VAR in INPUT statement. INPUT VAR &;
You should read about LIST, FORMATTED, COLUMN and NAMED input to understand the nuances of the INPUT statement and the interaction of INFORMAT INPUT and INFILE etc.
You can also use a helpful informat $varying.Such as:
data temp;
infile datalines length=len;
input var $varying200. len;
datalines;
............
Ksharp
I apologize for repling late.
Thank you all for great help.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.