I am using this array again for a similar purpose, and need some additional help.
<The SUBSTR function call has too many arguments.>
This time, the string is a maximum of 6 characters. Each value is 2 characters. In other words, a value of 010101 has 3 distinct values (01, 01, 01).
Ultimately, I want to create 3 new variables for each string:
IF VAR1=01 THEN NEW_VAR1=1; ELSE NEW_VAR1=0;
IF VAR2=01 THEN NEW_VAR2=1; ELSE NEW_VAR2=0;
Etc.
This code works for one variable:
DATA want;
SET have;
ARRAY answers (*) $ 2 VAR1-VAR3;
DO i = 1 to 3;
answers(i) = substr(_400203, i, 2);
END;
DROP
_400203
i;
RUN;
But this code does not work for multiple variables (In this example there are only 2 variables (_400203 and_400204), but I want to use it w/ 44 variables.
<The SUBSTR function call has too many arguments.>
DATA want;
SET have
ARRAY array_name (*) $ 2 VAR1-VAR6;
DO i = 1 to 6;
answers(i) = substr(_400203-_400204, i, 2);
END;
DROP
_400203
_400204
i;
RUN;
... View more