Hi Ksharp,
Its ok if the code is big and no IML and i dont need to make my variables character and we can remove put from the code
I tried to remove put and run it but I am getting the following error with below code
+ proc sql;
1 + create table test77 as
NOTE: Line generated by the CALL EXECUTE routine.
2 + select 1 as x,"cnt_id" as a length=12,"Pricing01 " as b length=100 from test7(obs=1) union select
2 !+2,count(customerid),_name_, from test7 group by pricing01
_____
22
76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &, (, *, **, +, ',', -, '.', /, <, <=, <>, =,
>, >=, ?, AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM, GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE,
LEN, LENGTH, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
Code I have used
data _null_;
set temp end=last;
if _n_=1 then call execute('proc sql;create table want as ');
call execute(cat('select ',n,' as x," cnt_id" as a length=12,"',
_name_,'" as b length=100 from have(obs=1) union select ',n+1,
',count(customerid),_name_, from have group by ',
_name_));
if not last then call execute(cat('union select ',n+2,'," "," " from have (obs=1) union'));
else call execute(';quit;');
run;
Thanks for your help
... View more