BookmarkSubscribeRSS Feed
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

 Hello Friends, 

how to access a long database tablename which has specical character like /, _,.?

Any help would be appreciated. Thank you.  

6 REPLIES 6
HB
Barite | Level 11 HB
Barite | Level 11

I would change the name of the table. 

Reeza
Super User
Have you tried the NLITERAL approach?

schema.'Table/Name'n
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

Thank you Reeza, can you please provide example? Thank you. 

Reeza
Super User

It was below...more explicitly, something like this:

 

 

data want;
set schema.'Table/Name'n;
run;
Reeza
Super User

The name can include special characters, except for the / \ * ? " < > |: -. characters.

 

Several of your characters fall into the characters that cannot be included unfortunately. You will need to rename them.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/nlsref/n10nwm6blrcrtmn0zdcwyxlwxfjh.htm

Tom
Super User Tom
Super User

To allow SAS code to use non-standard names for datasets (members) you need to the VALIDMEMBERNAME option to EXTEND.  But even then there are some characters, like / , that are not allowed.

 

You mentioned that the data is in a database.  Use a pass through query to access the data.

For example if you have a libref defined that points to some external database, like ORACLE,

libname mydb oracle ... ;

You can use that LIBREF in SQL code like this.

proc sql;
connect using mydb;
create table want as select * from connection to mydb
(select * 
  from "mygoofy or long table name"
);
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 301 views
  • 4 likes
  • 4 in conversation