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

Hello Everybody,

I am importing huge file ( so many columns) and run below query.

PROC IMPORT OUT=WORK.test DATAFILE="~\data.XLS"

  DBMS=XLS REPLACE;

  SHEET="Sheet1";

  GETNAMES=YES;

RUN;

I found that my column names has spaces in final sas dataset also. For example 'var one' came as 'var one' but I was expecting it will come as var_one. I am wondering if there is a way to make sure that all variables are named as SAS convention as we create tables using file from Excel.

I know I can do it using file>>import data and clicking in rename variables as sas convention in EG but I am looking if it can be done using proc import procedure.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. Are you sure that's what's happening? SAS has variable labels and names, the labels may have spaces but the names won't.

2. Look at the validvarname option.

option validvarname=ANY - this allows spaces

OPTION VALIDVARNAME=V7 - will allow the standard SAS naming convention, i.e. using underscores.

Change the option in EG if you require and re-importing will allow the names to be imported as you expect.

SAS(R) 9.3 System Options: Reference, Second Edition

View solution in original post

2 REPLIES 2
Reeza
Super User

1. Are you sure that's what's happening? SAS has variable labels and names, the labels may have spaces but the names won't.

2. Look at the validvarname option.

option validvarname=ANY - this allows spaces

OPTION VALIDVARNAME=V7 - will allow the standard SAS naming convention, i.e. using underscores.

Change the option in EG if you require and re-importing will allow the names to be imported as you expect.

SAS(R) 9.3 System Options: Reference, Second Edition

learner_sas
Quartz | Level 8

Thank you @reeza. It worked.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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