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

 I have created a macro that creates a new table based on an SQL procedure that pulls data from some SQL tables. This macro is below and works without any problems as expected:

 

%macro Pull_Data_from_db(database, server, portid, tblname);

	%let libraryname = db;
	
proc sql;
	
	connect to oledb (init_string="Provider=SQLOLEDB; Integrated Security=SSPI; Initial Catalog=&database.; data source=&server." schema=dbo);
			create table &tblname. as select * from connection to oledb (

	SQL code;
quit;
%mend;

I next want to create a macro that will take this macro putting it into a loop and run it on multiple tables. So far I have put the function into a new function and tried running it in that function and rather than just connecting I get a pop up asking to specify Data Link Properties.

 

%macro Pull_Multi_tables_from_db(database, server, portid, tblname);

	%Pull_Data_from_EDM(database, server, portid, tblname);

%mend;

 

Is there a reason my macro is able to connect properly when run by itself but not when put into a second macro?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
chris_e
Obsidian | Level 7

Sorry just realised I needed to put & on the front of the variables and . on the end in the second function.

 

%macro Pull_Multi_tables_from_db(database, server, portid, tblname);

	%Pull_Data_from_EDM(&database., &server., &portid., &tblname.);

%mend;

View solution in original post

1 REPLY 1
chris_e
Obsidian | Level 7

Sorry just realised I needed to put & on the front of the variables and . on the end in the second function.

 

%macro Pull_Multi_tables_from_db(database, server, portid, tblname);

	%Pull_Data_from_EDM(&database., &server., &portid., &tblname.);

%mend;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 867 views
  • 0 likes
  • 1 in conversation