Dear all, I want to creata a empty data based on the demographic data . In the empty data, there are differnet columm based on the group variable. However, somehow, my " do --end " statements gave me error message. Please see below for the original codes , and log message. May you help ? Thank you very much. %let indsn = demo ; %let by = PCM ; proc sql; select distinct &by into: by_grp separated by " " from &indsn ; quit; %put &by_grp ; %let gr_cnt=%sysfunc(countw(&by_grp)); %put &gr_cnt; proc sql; create table rpt_cat ( var_level char(50), var char(50), ptpct char(50), rord num, %do j = 1 %to &gr_cnt; %scan(&by_grp, &j) char(50) , %end; pv char(50) ) ; quit; 4673 %let indsn = demo ; 4674 %let by = pcm ; 4675 4676 4677 proc sql; 4678 select distinct &by into: by_grp separated by " " from &indsn ; 4679 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 4680 %put &by_grp ; Non-PCM PCM 4681 4682 %let gr_cnt=%sysfunc(countw(&by_grp)); 4683 %put &gr_cnt; 3 4684 4685 proc sql; 4686 create table rpt_cat ( 4687 var_level char(50), 4688 var char(50), 4689 ptpct char(50), 4690 rord num, 4691 %do j = 1 %to &gr_cnt; ERROR: The %DO statement is not valid in open code. 4692 %scan(&by_grp, &j) char(50) , WARNING: Apparent symbolic reference J not resolved. WARNING: Apparent symbolic reference J not resolved. ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &j ERROR: Argument 2 to macro function %SCAN is not a number. 4692 %scan(&by_grp, &j) char(50) , - 22 ERROR 22-322: Syntax error, expecting one of the following: CHAR, CHARACTER, DEC, DECIMAL, FLOAT, NUM, NUMERIC, VARCHAR. 4692 %scan(&by_grp, &j) char(50) , - 76 ERROR 76-322: Syntax error, statement will be ignored. 4693 %end; ERROR: The %END statement is not valid in open code. 4694 pv char(50) 4695 ) ; 4696 quit;
... View more