Skip to content
Advertisement

How to query SSMS via SAS EG ODBC connection while using data from WORK?

Is there a way to send a SAS dataset through a proc sql odbc query in SAS EG so that it can be taken in and used by SQL server?

ex)

SAS Data WORK.A contains 3 columns ID, col1, col2. I have a table in Sql Management Studio environment with the same ID column.

I would like to (somehow) do as shown in Figure A below:

Figure A)

This throws an obvious error in SAS as SSMS doesn’t understand what WORK.A is… It’s expecting pure SSMS code to be executed.

I have passed macro variables created in SAS through to SQL passthrough to be used in the WHERE statement like in figure B, but that has it’s limitations (especially with macro character length) and is not as elegant as passing a whole table.

Figure B)

Any ideas would be helpful.

Advertisement

Answer

Create a temporary table in SQL Server, against which you can perform your later pass through query.

Example:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement