BookmarkSubscribeRSS Feed
Rohit12
Obsidian | Level 7

%let table_no=EMP_HIST;


proc sql;
connect to oleDB as passThru
(properties=('Integrated Security'=SSPI 'Persist Security Info'=TRUE 'Initial Catalog'=DBDWH_EMP)
provider=SQLOLEDB PROMPT=NO DATASOURCE='DWH-I-SQL.DWHNET\DB01 schema=DWHDS);
create table work.temp_views as select
*
from connection to passThru (
SELECT
s.name as schema_name
,v.name as view_name
FROM sys.views v
,sys.schemas s
WHERE v.schema_id=s.schema_id
AND s.name like 'dwh'
AND v.name ="&table_no"
ORDER BY 1,2
);

disconnect from passThru;
quit;


ERROR: Describe error: IColumnsInfo::GetColumnInfo failed. : Deferred prepare could not be
completed.: Statement(s) could not be prepared.: Invalid column name
'EMP_HIST'.

 

 

Question -I am ruuning the above code and it seems that code is resloving the macro varibale table no but due to pass through method it is showing above error

 

What should I write to run this code  

2 REPLIES 2
SASKiwi
PROC Star

This is just a guess but some databases don't like double quotes so try this:

 

AND v.name = %str(%')&table_no%str(%')
Astounding
PROC Star

If that gives you trouble, apply %unquote:

 

AND v.name = %unquote(%str(%')&table_no%str(%'))

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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