BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ssbxvm
Calcite | Level 5

Hello everyone,

 

I'm importing data from a database view using a proc SQL statement.  Unfortunately I have no power over column names, and quite a number of the column names include a period in the name (e.g. VARIABLE.NAME).  I know that SAS will automatically rename the variable name if it contains non-standard characters.  Is there some option that I can use where SAS will replace the "." in a column name with an underscore as well when creating the dataset?

 

Right now I'm looking at having to use string literal for all SAS variable names that include a period.  I'd rather not do that since I already have pre-created formats for correctly named SAS variables. Thank you!

 

PROC SQL;
CREATE TABLE RANDOM_NAME
AS SELECT * FROM Database.View;
QUIT;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
options validvarname=v7;

If you have this option set, SAS should convert it to the appropriate names. 

 


@ssbxvm wrote:

Hello everyone,

 

I'm importing data from a database view using a proc SQL statement.  Unfortunately I have no power over column names, and quite a number of the column names include a period in the name (e.g. VARIABLE.NAME).  I know that SAS will automatically rename the variable name if it contains non-standard characters.  Is there some option that I can use where SAS will replace the "." in a column name with an underscore as well when creating the dataset?

 

Right now I'm looking at having to use string literal for all SAS variable names that include a period.  I'd rather not do that since I already have pre-created formats for correctly named SAS variables. Thank you!

 

PROC SQL;
CREATE TABLE RANDOM_NAME
AS SELECT * FROM Database.View;
QUIT;

 


 

View solution in original post

2 REPLIES 2
Reeza
Super User
options validvarname=v7;

If you have this option set, SAS should convert it to the appropriate names. 

 


@ssbxvm wrote:

Hello everyone,

 

I'm importing data from a database view using a proc SQL statement.  Unfortunately I have no power over column names, and quite a number of the column names include a period in the name (e.g. VARIABLE.NAME).  I know that SAS will automatically rename the variable name if it contains non-standard characters.  Is there some option that I can use where SAS will replace the "." in a column name with an underscore as well when creating the dataset?

 

Right now I'm looking at having to use string literal for all SAS variable names that include a period.  I'd rather not do that since I already have pre-created formats for correctly named SAS variables. Thank you!

 

PROC SQL;
CREATE TABLE RANDOM_NAME
AS SELECT * FROM Database.View;
QUIT;

 


 

ssbxvm
Calcite | Level 5
I knew it had to be something simple. Thank you!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2216 views
  • 0 likes
  • 2 in conversation