1. Would the code below be correct (using in ([all of the GROUP results from 1-5]) so that BAND_1_to_5 has a result of 'Yes' when GROUP=1, GROUP=2, GROUP=3, GROUP=4 and GROUP=5 only (see code below)?
data test2;
set test;
length Band_1_to_5 $3;
if BAND in ('GROUP = 1', 'GROUP = 2', 'GROUP= 3', 'GROUP = 4', 'GROUP = 5') then BAND_1_to_5 = 'Yes';
else BAND_1_to_5 = 'No';
run;
2. OR can I put the code
(if BAND in ('GROUP = 1', 'GROUP = 2', 'GROUP= 3', 'GROUP = 4', 'GROUP = 5') then BAND_1_to_5 = 'Yes';
else BAND_1_to_5 = 'No'; )
in the code written above, so that both that both new variables, BAND and BAND_1_to_5 are BOTH included in the just the one 'test' dataset (i.e. everything is created from just one DATA step).
[1] Do you want the combination in 1. to be all 5 to simultaneously true to take value 'YES'? Or if one of them (eg. 'GROUP = 4' ) is true then do you want 'YES'.
A better way will be to add few records in DATALINES and show an output you require out of it.
... View more