BookmarkSubscribeRSS Feed
karachi007
Calcite | Level 5

Tom, No luck

this is my code:

 

%macro test(DSN):

 

proc sql;

create connection to ORACLE ,,,,,,,

   create table employee_&DSN. as

  

  select * from .&DSN. a

   left join employee e

   on a.id = e.id;

 run;

%mend test;

%test(FILE1,FILE2)

quit;

 

getting errors:

 

more positional parameters found than defined

 

please advise and let me know the issue. Thank

 

 

Patrick
Opal | Level 21

@karachi007 

It is a common beginners problem to try and use SAS Macro language for a problem that should be addressed differently. It's much better to first better skill up in normal SAS language before even attempting to use SAS Macro language.

 

I believe we could give you better advice if you can tell us what bigger problem you want to solve. Share the bigger picture with us? What do you have to start with, what do you need as target state and where you're stuck and need help with? - A description of the problem like: A bunch of SAS tables in a source library to be loaded into same named tables in Oracle. Dynamic code required to just pick-up whatever tables are in source. Succeeded to write the load code for a single table but don't manage to make the code dynamic.

Kurt_Bremser
Super User

@karachi007 wrote:

Tom, No luck

this is my code:

 

%macro test(DSN):

 

proc sql;

create connection to ORACLE ,,,,,,,

   create table employee_&DSN. as

  

  select * from .&DSN. a

   left join employee e

   on a.id = e.id;

 run;

%mend test;

%test(FILE1,FILE2)

quit;

 

getting errors:

 

more positional parameters found than defined

 

please advise and let me know the issue. Thank

 

 


The ERROR message is very clear and obvious: you defined the macro with only ONE parameter, and then tried to call it with TWO parameters. This is not possible.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 2652 views
  • 2 likes
  • 5 in conversation