DATA Step, Macro, Functions and more

Sas SQL to tSQL

Posts: 45

Sas SQL to tSQL

Is there any way to export  sas SQL to tSQL ?


Super User
Posts: 3,927

Re: Sas SQL to tSQL

SAS SQL is constructed between a PROC SQL statement and a closing semicolon, possibly followed by a QUIT statement.

proc sql;

create table table1 as

select *

from ............;


If you simply copy the bolded SQL into your tSQL editor it will in some cases work unmodified. You may have to tweak it to get it to work but for simple queries that shouldn't be a lot of work.

If you wish to do this a lot and repeatedly then you should use SAS's SQL Pass-through. In that case the SQL being used would be identical to tSQL.

Super User
Posts: 5,884

Re: Sas SQL to tSQL

As you might have guesse from :s answer, the direct answer for your question is no, not any SAS Institute supported one at least.

Since SAS SQL programs are plain text files, there is nothing stopping anyone to write some kind of parser program to re-program to t-SQL - but I never heard of any such tool. In fact, this is what SAS/ACCESS to OLEDB/ODBC does behind the curtain - reprogram to native DBMS engine SQL. But I don't think that you can fetch this code on the fly, at least not from SAS.

But, why do you ask, what is your underlying requirement?

Data never sleeps
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation