Hello,
Maybe someone can help me with macro
I need to get macro like this: from egtask.report_(&(PLIK&NUM.)) //* it consists with &NUM. - from %do statement (1,3) and &plik(1,3)
proc sql; select nr_pliku into:plik1 from pliki_1 where poreczenia=1 ;quit; //* here I have into:plik1 =3
proc sql; select nr_pliku into:plik2 from pliki_1 where poreczenia=2 ;quit; //* here I have into:plik2 =1
proc sql; select nr_pliku into:plik3 from pliki_1 where poreczenia=3 ;quit; //* here I have into:plik3 =2
///*parametrs plik1/2/3 in this macro will change therefore I need this macro in loop
%macro sqlloop(start,end);
%DO NUM=&start. %TO &end.;
PROC SQL;
create table title&NUM. as select *
FROM egtask.report_(&(PLIK&NUM.).) ///* when &NUM.=1 then &plik1, when &NUM.=2 then &plik2.
;QUIT;
%END;
%mend;
%sqlloop(start=1, end=3)
Thank You in advance 🙂
please try (&&PLIK&NUM.)
%macro sqlloop(start,end);
%DO NUM=&start. %TO &end.;
PROC SQL;
create table title&NUM. as select *
FROM egtask.report_(&&PLIK&NUM.) ///* when &NUM.=1 then &plik1, when &NUM.=2 then &plik2.
;QUIT;
%END;
%mend;
%sqlloop(start=1, end=3)
please try (&&PLIK&NUM.)
%macro sqlloop(start,end);
%DO NUM=&start. %TO &end.;
PROC SQL;
create table title&NUM. as select *
FROM egtask.report_(&&PLIK&NUM.) ///* when &NUM.=1 then &plik1, when &NUM.=2 then &plik2.
;QUIT;
%END;
%mend;
%sqlloop(start=1, end=3)
Thank You very much!
Hi @Irena_ik
I believe that the parenthesis prevents the macro resolution: &(PLIK&NUM.).)
Please try &&PLIK.&NUM. instead.
Best,
Thank You for help!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.