1
votes

Could someone please provide an explanation or a link which has explanation on the functionality of ':' in the below code:

data voter; 
infile datalines dsd dlm='~'
input age party : $1. (ques1 - Ques4) ($1. + 1); 

format age 2. party $1. ques1 - ques4 $likert.;
label Ques1 = ' performance '
        Ques2 = ' taxes '
        Ques3 = ' amenities '
        Ques4 = ' endurance ';
datalines;
23~D~2~1~3~4 
34~R~2~1~4~4 
43~D~2~2~1~1 
;

This is the test code used for learning SAS. When I remove the ':' from the INPUT statement I am not able to read the data properly. Also, kindly let me know what is the +1 in the ($1. + 1); context. This snippet is taken from learning SAS through examples. Thanks in advance.

1

1 Answers

2
votes

: is called colon operator which means - to stop reading when encounter a delimiter, Because it is list input method, so point will move a unit forward

(Ques1-Ques4) ($1. +1);

is the same as Ques1 $1. +1 Ques2 $1. +1 Ques3 $1. +1 Ques4 $1. +1 i.e. Increament +1 position for Ques2 from Ques1 and so on.