Help using Base SAS procedures

dsn and schema

Reply
Regular Contributor
Posts: 222

dsn and schema

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;

Regular Contributor
Posts: 222

Re: dsn and schema

Posted in reply to Mike_Davis

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 )

Super User
Posts: 19,772

Re: dsn and schema

Posted in reply to Mike_Davis

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.

Regular Contributor
Posts: 222

Re: dsn and schema

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

Super User
Posts: 19,772

Re: dsn and schema

Posted in reply to Mike_Davis

Are the table names longer than 32 characters?

Frequent Contributor
Posts: 95

Re: dsn and schema

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

Contributor
Posts: 34

Re: dsn and schema

Posted in reply to Mike_Davis

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.

Super User
Posts: 10,023

Re: dsn and schema

Posted in reply to Mike_Davis

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

Ask a Question
Discussion stats
  • 7 replies
  • 950 views
  • 3 likes
  • 5 in conversation