Hi all, The problem has been solved by dividing the data set by variables and conditions, checking separately and merging together. Many thanks to all. Regards, SH %macro kategoryzuj;
%global test;
%put &test;
proc sql noprint;
select count(*) into :ile_war
from wyj.warunek;
quit;
%put &ile_war;
proc sql noprint;
select zmienna into :zmien_kat separated by " "
from wyj.lista_zmiennych_il;
quit;
proc sql noprint;
select count(zmienna) into :count_zm
from wyj.lista_zmiennych_il;
quit;
data wyj.vin_kat;
set wyj.vin (keep = aid fin_period vin1 vin2 vin3);
run;
%do c=1 %to &count_zm;
%let zmien = %scan(&zmien_kat,&c," ");
%put &zmien;
data t.warunek_iter;
set t.warunek;
zmienna = lowcase(trim(left(zmienna)));
run;
data t.warunek_iter;
set t.warunek_iter;
where zmienna = "&zmien";
run;
proc sql noprint;
select warunek into :test separated by ' X'
from wyj.warunek_iter order by warunek;
quit;
proc sql noprint;
select count (*) into :iter
from wyj.warunek_iter;
quit;
%do i = 1 %to &iter;
%let war = %scan(%scan(&test,&i,'X'),3,'A');
%let wart = %scan(%scan(&test,&i,'X'),2,'A');
data war&c._&i;
set wyj.vin (keep = aid &zmien);
where &war;
run;
data war&c._&i;
set war&c._&i;
if &war then &zmien = &wart;
run;
%end;
data war_&c;
length aid $16;
length &zmien 8;
delete;
run;
%do j=1 %to &iter;
data war_&c;
set war_&c war&c._&j;
run;
%end;
proc sort data = war_&c;
by aid;
run;
proc sort data = wyj.vin_kat;
by aid;
run;
data wyj.vin_kat;
merge wyj.vin_kat(in=z) war_&c;
by aid;
if z;
run;
%end;
%mend;
%kategoryzuj;
... View more