BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6

Hello everyone,

Does anybody could explain the meaning of code to me?

Thank you!

proc sql;

connect to odbc as xyzp (dsn=asdf user=wind pw=cool);

execute (exec [xyz].[dbo].[sp_report_indexCreate]) by xyzp;

quit;

2 REPLIES 2
Nigel_Pain
Lapis Lazuli | Level 10

Mike

This executes a stored procedure on what looks like a SQL Server database using SAS/Access for ODBC.

The connect statement establishes a connection to the database: the details of this are in the dsn (Data Source Name) specified - this would specify the server, port and database names (use your ODBC manager software to see these) and the user and pw options specify the authentication credentials. The "as xyzp" part establishes an alias: without it you would have to replace any references to "xyzp" with "odbc". You could conceivably have several ODBC connections on the go and so you would need to be able to differentiate between them when passing code to them. But if you only have the one connection the alias isn't strictly necessary. The execute statement passes the contents of the parentheses directly to the database to run itself. Any output would be passed back to SAS.

One thing that the code is missing is a disconnect statement: this should go between the execute and quit statements and consist of:

disconnect from xyzp;

I'm afraid I'm not very up on SQL Server so I can't really help with the details of the stored procedure that is run in this case. I think the [dbo] bit specifies the schema and the [sp_report_indexCreate] specifies the procedure name but I don't know what the [xyz] bit is.

Hope this helps,

Nigel

Mike_Davis
Fluorite | Level 6

Thank you very much.

for sql server,using T-SQL

here is an example of  create a stored procedure one with a parameter x :

CREATE PROCEDURE one @x char(10)
AS
SELECT *
FROM sashelp.class

WHERE x= @x
go


To call this stored procedure one :


EXEC one @x = 'M''

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
  • 709 views
  • 3 likes
  • 2 in conversation