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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.