I was wondering if there's a difference between, for example, using:
LENGTH var_1 $12.; INPUT var_1 $;
vs
INPUT var_1 : $12.;
when reading in standard input from datalines or an external file;
They are the same as long as the LENGTH or the INPUT statement is the first place that the SAS compiler sees VAR_1 referenced and needs to decide what type and length to assign to it. Both will cause VAR_1 to be defined as a character variable of length 12. The LENGTH statement will do it explicitly and the INPUT statement will do it as a side effect. SAS assumes that you wanted the type to be character since you used a character informat. It also assumes that you want the length to be same as the width on the informat. (Note that that you could reference the variable in a RETAIN statement before hand and SAS will not make the decision as to the type and length at that time.)
Both INPUT statements will read VAR_1 in list mode because the second one includes the :
modifier before the informat specification. So SAS will read the next word it sees (which depend on settings of DSD and TRUNCOVER options and whether the &
modifier is used) into the VAR_1, even if the next word is longer than 12 characters. When you read data using list mode instead of formatted mode then SAS will actually ignore the width of the informat and read the number of characters in the next word. So if the next word is longer than 12 characters the extra characters will be ignored.
Note that if you have already defined VAR_1 as being a character variable then you do not need to add the $
after it in the INPUT statement in your first case.