I would like to convert a variable that combined all information about requirements for each statement and we need to make about 30 dummy variables (this is the number of special requirements). We have two types of such requirements: regular (R) and special (S). Every statement has R requirement(s) but not every has S requirements. For example for a statement: !S3, 4 !R22 which means this statement has two special requirements (#3 and #4) and one regular requirement (#22). Based on such information I need to convert it to S1=0, S2=0, S3=1, S4=1. S5=0 and R1=0, R2=0, ..., R21=0, R22=1, R23=0, ..., R25=0.
Note. the code for the type of requirement starts with ! and separate among the requirement of same type by a comma and between the two types of requirements by a space.
I agree with Reeza, and suggest the "input record buffer" be parsed using one of a few different DATA step functions, likely considering maybe SCAN, FIND, SUBSTR, INDEX, INDEXC, and possibly VVALUE or VVALUEX for assignment.
Suggested DATA step structure approach demonstrated below:
* RECOMMEND CODING SAS ATTRIB OR LENGTH STATEMENTS ;
* HERE TO DECLARE EXPECTED SAS VARIABLES. ;
* COME HERE FOR INFINITE LOOP TO PARSE CURRENT INPUT ;
* RECORD AND DECODE ONE OR MORE SUB-FIELDS. ;
LENGTH TEMPVAR $1000;
TEMPVAR = SCAN(_INFILE_,I,'!');
* EXIT THE DO LOOP NOW WHEN NO MORE FIELDS TO PARSE. ;
IF TEMPVAR = ' ' THEN LEAVE;
* YOUR PARSING CODE FOR EACH RECORD SUBTYPE/FIELDS GOES HERE.;