thanks guys for your suggestions.... I like Reeza's simple SQL suggestion but not able to proceed with it. I guess I didn't understand what to include instead of "from SASHELP.class" never used it in mainframe before. As explained below trying to execute SQL statement only for the first Data Step iteration. here is what I my code IF _N_ = 1 THEN DO; SET INFOP; TDATE = TODAY(); proc sql noprint; select quote(trim(substr(ctyp,1,1))) into :cltye separated by ", " from sashelp.class; %put &cltye; END; and here is what I got:. Apparently doesn't like it the sql? what I did wrong? 101 IF _N_ = 1 THEN DO; 102 SET INFOP; 103 TDATE = TODAY(); 104 proc sql noprint; _ 117 ERROR 117-185: There was 1 unclosed DO block. ERROR: SAS ended due to errors. I even tried inserting the sql in a separate block and this is what I got... 01 IF _N_ = 1 THEN DO; 02 SET INFOP; 03 TDATE = TODAY(); 04 END; 05 IF _N_ = 1 THEN 06 proc sql noprint; ____ 180 07 select quote(trim(substr(ctyp,1,1))) _____ 22 RROR 180-322: Statement is not valid or it is used out of proper order. RROR 22-322: Syntax error, expecting one of the following: (, ;. 08 into :cltye separated by ", " ____ 22 76 RROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, - IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ¬, ¬=, |, ||, ~, ~=. RROR 76-322: Syntax error, statement will be ignored. -------------------------------------------------------------------------------------------------------------------------------------- Then I also tried Amir's elegant solution... and I am stuck with the apparent symbolic reference x not resolved. 106 invalues=quote(substr(ctyp,1,1)); 107 do until(lengthn(ctyp)=1); 108 ctyp=substr(ctyp,2); 109 invalues=catx(',',invalues,quote(substr(ctyp,1,1))); 110 put 'ctyp ' ctyp ' invalues ' invalues; 111 call symput('cltype',invalues); 112 %put &cltype; WARNING: Apparent symbolic reference CLTYPE not resolved. &cltype 113 end; I should come back with Peter's suggestion So, what should I do? Thanks guys, Miguel
... View more