SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kjohnsonm
Lapis Lazuli | Level 10

Hello all,

Does anyone have a hint on how I can read just the table names in an entire MS SQL libname into sas?

 

For example:

 

proc sql;
create table temp as
SELECT TABLE_NAME
FROM my_lib.[INFORMATION_SCHEMA].[COLUMNS]
WHERE TABLE_NAME LIKE 'xw_%';
QUIT;

 

I have tried dropping the [], I have tried dropping ".[COLUMNS]"

I have tried making a temp table from the source MS SQL DB on this data, so I can just read a non-schema table directly like any other regular data set.   It shouldn't be that hard what am I missing?

last I have tried a proc

print data=sashelp.vcolumn noobs;

var memname name type [... etc];

where libname='my_lib';

run;

 

This last item seems to have hung my SAS app.  I can read and write to this libname for other tables.   TIA.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Also for sashelp.vcolumns the entries are case sensitive. 

Youve stated table names, is there a reason your not using vtable instead of vcolumn?

View solution in original post

5 REPLIES 5
Reeza
Super User

Try a proc datasets though sometimes for DB it's all blanks. 

kjohnsonm
Lapis Lazuli | Level 10
"Try a proc datasets though sometimes for DB it's all blanks." ---I am not sure what you mean buy this idea, however your other comment was spot on.
Reeza
Super User

See the output from the following. 

 

Proc datasets library=libname;

run;quit;

 

 

Reeza
Super User

Also for sashelp.vcolumns the entries are case sensitive. 

Youve stated table names, is there a reason your not using vtable instead of vcolumn?

kjohnsonm
Lapis Lazuli | Level 10
Thanks for the reminder. I forgot about case ...

proc print data=sashelp.vcolumn noobs;
where lower(libname)='my_lib';
run;

PS I also figured out the MS SQL side, the "table name" is MS's word sorry for that one, I did not fully translate the code from MS SQL to SAS.

SELECT distinct TABLE_NAME INTO my_xw_tables FROM [my_db].[INFORMATION_SCHEMA].[COLUMNS] where TABLE_NAME like 'xw_%';

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 5 replies
  • 2332 views
  • 2 likes
  • 2 in conversation