BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Irena_ik
Fluorite | Level 6

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 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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)
Thanks,
Jag

View solution in original post

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

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)
Thanks,
Jag
Irena_ik
Fluorite | Level 6

Thank You very much!

ed_sas_member
Meteorite | Level 14

Hi @Irena_ik 

 

I believe that the parenthesis prevents the macro resolution: &(PLIK&NUM.).) 

Please try &&PLIK.&NUM. instead.

Best,

 

Irena_ik
Fluorite | Level 6

Thank You for help!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 632 views
  • 2 likes
  • 3 in conversation