I want to write a code where under certain condition a different proc tabulate will be executed. The problem is somewhere inside macro. Without changes everything worked just fine. The idea of code is quite simple but it is the first time I have ever made something like that. Depending on value x in data makro different macro will be executed. I do not know how variables should be defined inside the macro.
data makro;
set number;
if number < 20 then x=1;
else x=2;
run;
proc format;
value temp 70- HIGH='red';
run;
PROC SQL;
CREATE TABLE Stat_for_&cel AS
SELECT distinct t1.&zmienna,
t1.&cel,
t2.number,
(COUNT(t1.cid)) AS ILE
FROM zrodlo.abt_app t1 left join ile_zmiennych t2 on t1.&zmienna=t2.&zmienna where t1.&zmienna not is missing
GROUP BY t1.&zmienna,
t1.&cel
ORDER BY t1.&zmienna DESC;
QUIT;
%macro tabelka1(Statystyka_dla_cel,&ILE,&cel,&zmienna);
proc format;
value temp 70- HIGH='red';
run;
PROC TABULATE
DATA= &&Stat_for_&cel format=commax10.2 ;
VAR &&ILE;
CLASS &&zmienna/ MISSING;
CLASS &&cel/ MISSING;
TABLE
/* Row Dimension */
&&cel,
/* Column Dimension */
&&ILE* ColPctSum* &&zmienna*[style=[background=temp.]];
RUN;
%mend tabelka1;
data makro_2;
set makro;
if x=1 then call execute ('%tabelka1');
run;
EDIT: Added information from 'answer' as it's not an answer.
code should work like that . &Cel and &zmienna are just variables which i want to use in proc tabulate procedure and which are defined manually at the beginning of the code. I want to run macro just once when 'number' is <20. In next few steps i just prepare data with proc format and also create a table 'Stat_for_&cel' which is later used as a data in proc tabulate procedure.
Main problem is inside the %macro tabelka1 , I believe. I do not know how should I implement the variables &cel and &zmienna inside the macro.