BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,
I want to run a sql server stored procedure called "getdata" that has two parameters which returns a certain result-set, which if I were to call from within sql server query analyzer would look like this:

EXEC dbo.getdata 1,null

This runs the getdata stored procedure by passing in a "1" as the value of the first parameter, and a "null" as the value of the second parameter.

How do I call this from SAS? Here's how I normally use SQL pass-thru to get to the database in question:

proc sql;
connect to odbc as DW (dsn="blah" uid=xxxx pwd=xxxx);
create table SAMPLE as
select * from connection to DW (
BLAH BLAH BLAH
);
quit;

thanks!
2 REPLIES 2
LinusH
Tourmaline | Level 20
Hi.
your option would might be using a EXECUTE statement in proc sql. It allows you to call stored procedures within your DBMS. But it has the following limitation (from on-line doc):

"However, stored procedures with output parameters are not supported in the Pass-Through Facility."

If your result set is other than just a return code (obtained by &SQLXRC and &SQLXMSG), I think you have to find another way to pass the result to SAS (using some other interface or store the result as an external file).

Regards,
Linus
Data never sleeps
deleted_user
Not applicable
I was able to get a result set back by calling this SQL stored procedure with two input parameters (in example below the parameters are 0, null) with this syntax:

proc sql;
connect to odbc as DW (dsn="blah" uid=xxxx pwd=xxxx);
create table TMP as
select *
from connection to DW (
EXEC dbo.spName 0,null
);
quit;

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
  • 2 replies
  • 587 views
  • 0 likes
  • 2 in conversation