Hello everyone,
when I connect to SQL server with SAS ,I use the code as below.
Could anybody please help me explain what is the defference between sdn and schema?
Thanks!
Mike
libname mydatas odbc
dsn=name1
schema=dbo;
seems like dsn(data source name) denotes database's name
schema specify a subfolder under this database(there would be many tables(datasets) under the schema specified folder, these tables(datasets) will be listed in under the libname folder of SAS )
That's a good way to think of it.
In SQL you refer to tables using a two level system schema.table_name and then variables with a three level system, schema.table_name.variable_name
SAS uses different notation so you need to specify your schema in the database connection to allow SAS to appropriately transfer the names.
I've seen the schema used to differentiate different programs that are stored/warehoused in the same db.
Thank you Sapper,
After the libname statement was finished,I found some of these tables in the SQL server didn't show up in the SAS folder. what cause this happen?
Thanks!
Mike
Are the table names longer than 32 characters?
If the table names are longer than 32 characters one way they can be accessed is by using SQL Pass Through.
proc sql;
connect to odbc(dsn=name1);
create table x as
select *
from connection to odbc(
select *
from dbo.<sqlservertablenamelongerthan32characters>
);
disconnect from odbc;
quit;
Zafer
Mike,
http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#titlepage.htm
Check the link out and it has database specific properties of the connection string. This should help you out!
Thanks
SAPPER.
Does your table name contain some special character , such as white blank $ # ?
And use libname option reserve_table_names=yes can update and display it.
Ksharp
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.
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.