If you change the spaces to a visible character is becomes more obvious.
infile cards dlm=',' dsd truncover;
input var1 var2 $ var3;
cards;
.,,,120
;
Since you told it to use DSD option the last line has 4 values on it instead of the 3 the INPUT statement is expecting.
If you want to use a value that has the delimiter in it then the value must be quoted. So using the version with commas so it is easier to see that means:
infile cards dlm=',' dsd truncover;
input var1 var2 $ var3;
cards;
.,",",120
;
Now there are three values. The second one consisting only of one copy of the delimiter character.
The easier solution is to use . in the data files to represent missing for both numeric and character values. The normal informat will interpret a single period as missing. If you want to actually read that as a character string '.' you need to use the $CHAR informat instead. And since your delimiter is a space there is generally no need for DSD option.
data t;
infile cards truncover;
input var1 var2 $ var3;
cards;
1 a 10
1 a .
1 b .
2 b 20
2 b 30
2 b 40
3 a 50
3 b .
3 a 60
3 b 70
3 a 80
3 a 90
3 a 100
. a 110
. . 120
;
Normally you don't want to use DSD when space is the delimiter. Humans use spaces to make the columns look neater.
... View more