As the SAS Documentation for the INPUT Statement says:
+n moves the pointer n columns.
Consequently, you take explicit control of the input pointer in your first data step and correctly jump over the spaces. In your second data step, the data step reads just a single character (as you instruct it to) regardless of whether it is a space or not.
Consequently, if your INPUT Statement in the second data step should produce the same output as the first one, your data should look like this (i don't recommend it, but I post it for clarification)
cdata voter2;
input Age Party : $1. (Ques1-Ques4) ($1.);
datalines;
23 D 1122
45 R 5541
67 D 2433
39 R 4444
19 D 2121
75 D 3323
57 R 4344
;
run;
Or you can simply add a colon to your input statement like this
data voter2;
input Age Party : $1. (Ques1-Ques4) (:$1);
datalines;
23 D 1 1 2 2
45 R 5 5 4 1
67 D 2 4 3 3
39 R 4 4 4 4
19 D 2 1 2 1
75 D 3 3 2 3
57 R 4 3 4 4
;
run;
... View more