BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Elliott
Obsidian | Level 7

Hi, 

I have a new sql server table data source that I need to query but several of the variables have hyphens in the variable names.

I am using a SAS pass through query to access the SQL Server database/view.

How do I get SAS to accept the non standard names?  I plan on renaming to change the hyphen to an underscore but right now I cannot even read them in.

Any assistance will be greatly appreciated.

Thanks,

Elliott

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

If you use this option SAS will automatically change the column names from hyphens to underscores when reading these tables:

options validvarname = V7;

If you need to refer to the original names in code then do this 'LETTER-REF-NUM'n

View solution in original post

5 REPLIES 5
SASKiwi
PROC Star

If you use this option SAS will automatically change the column names from hyphens to underscores when reading these tables:

options validvarname = V7;

If you need to refer to the original names in code then do this 'LETTER-REF-NUM'n

Elliott
Obsidian | Level 7

I have tried options validvarname = V7; and options validvarname = any; neither work, still erroring with not valid SAS name.

Patrick
Opal | Level 21

@Elliott wrote:

I have tried options validvarname = V7; and options validvarname = any; neither work, still erroring with not valid SAS name.


This should work. Please provide the code and log where you still encounter errors.

Options That Affect SAS/ACCESS Naming Behavior

Reeza
Super User
If you're using SQL passthru rename them when you pull them to valid SAS names.

Ie for Oracle

Select "First Name" as first_name,
.....
from customers;
quit;
Elliott
Obsidian | Level 7

I was able to read in the data using "LETTER-REF-NUM"n

 

Thanks All for your help.

 

Elliott

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 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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 675 views
  • 0 likes
  • 4 in conversation