I am accessing an MS SQL Server database that contains tables and view with the same object names (i.e. FRED.TABLE and FRED.VIEW both exist in the schema), but the tables and views folders. I know that the views are better curated for querying in SAS but I suspect that the LIBNAME statement is accessing the tables and not the views. Is there a way to point to the views in a MS SQL Server database and not the tables in SAS SQL or a DATA step?
I haven't tried it but you should be able to specify the VIEW extension in SQL Passthru:
select * from [MySQLServer].[MyDatabase].[MySchema].[MyTable].[VIEW]
It is common practice to actually name views like so: vw_MyTable rather than have exactly the same names in my experience.
I haven't tried it but you should be able to specify the VIEW extension in SQL Passthru:
select * from [MySQLServer].[MyDatabase].[MySchema].[MyTable].[VIEW]
It is common practice to actually name views like so: vw_MyTable rather than have exactly the same names in my experience.
Thank you for your response. You solution matches what I expected to see. I agree that normally views would be named to differentiate them from tables, but analysts in the business were not consulted when the database was architected. I can point directly to the views using pass through queries, but then I am dependent on another IDE to explore the tables. It is more convenient to use Libname statements in EG or SAS Studio so that the table structures are visible in the Library pane.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.