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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.