@emaguin wrote: I could have said array vlec16{5} A3LEC15_1 A3LEC15_3 A3LEC15_4 A3LEC15_6 A3LEC15_7; but why?? It's simpler to do what I did and then not use two of the variables and then delete them. So what! Like I said, understand the warning. But why did sas not execute the statement? It was a warning not an error. Gene Maguin
Because you did not "drop" A3Lec15_2 (or A3Lec16_2) you said the problem was with Lec16_2. You are now using different variable names than shown in your previous code snippet (A3Lec15). Which is one reason I asked for the entire data step, to see what you may be creating during the data step, exactly what you are "dropping". I strongly suspect you didn't create the variables that you claimed to attempt to drop.
A couple of other ways to parse comma delimited string of values and get a 1 or 1/0 coded variable.
data example;
infile datalines truncover;
input string $15.;
array v(7);
do i=1 to countw(string,',');
v[input(scan(string,i,','),f8.)]=1;
end;
datalines;
1
1,3
3,4,7
1,3,7
1,3,4,6,7
;
/* or to do 1/0 coding*/
data example;
infile datalines truncover;
input string $15.;
array v(7);
do i=1 to 7;
v[i]= index(string,put(i,f1.))>0;
end;
datalines;
1
1,3
3,4,7
1,3,7
1,3,4,6,7
;
Scan can pull a specific position number of a value from a delimited string. The last parameter is a list of delimiters. Lots simpler than trying to use the length and an offset. Probably not needed but sometimes you want to break up a string at different points and though it appropriate to include a specific delimiter in this example. The Index function returns a position in a string of a substring. SAS returns 1 for true or 0 for false with comparing the returned value from Index to > 0.
Index would not be appropriate for finding 1 if you might have values like 10, 11 or 101 though INDEXW or FINDW might.
I prefer 1/0 coded values for "any that apply" type questions because then a sum=total number of selections, mean=percentage of respondents that selected the choice.
BTW, 190 lines isn't particularly long for a data step.
... View more