BookmarkSubscribeRSS Feed
b77
Calcite | Level 5 b77
Calcite | Level 5

I run proc sql by connecting to sql server table (proc sql; connect to sqlsvr (dsn=table_name readbuff=15000))

I would like to run a proc contents on the table (dsn=table_name) but I must be getting the syntax wrong.  Is it even possible to run proc contents when connecting to SQL server?

 

Any help would be appreciated...

2 REPLIES 2
Quentin
PROC Star

When you use PROC SQL to connect to SQL server, you're using "explicit pass-through" to let you write Microsoft SQL Server code and send it to SQL server to execute.

 

You cannot use PROC CONTENTS in an explicit pass-through block because PROC CONTENTS is SAS code, not SQL Server Code.

 

If you want to run PROC CONTENTS on a SQL server table, you can use the LIBNAME statement to create a libref that points to the SQL server database.  Then you can run the usual PROC CONTENTS step:

libname mysqldb ... ;
proc contents data=mysqldb.mytable;
run;

When you do that, you're using "implicit pass-through".  You're submitting SAS code and telling SAS to translate it into SQL server code.

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.
Patrick
Opal | Level 21

On top of what @Quentin says: 

Proc Contents then will you show how the SQL Server columns map into SAS columns. It will not show you the SQL Server column types (like: a varchar on the SQL Server side will map into a CHAR on the SAS side and that's what Proc Contents will show).

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 157 views
  • 0 likes
  • 3 in conversation