Desktop productivity for business analysts and programmers

missing underscore in Sas variable names

Posts: 39

missing underscore in Sas variable names

I am running the following macro in SAS EG.

The SAS dataset created does NOT have underscores between column names containing 2 or more words. For example, Branch Number does NOT become Branch_Number, but stays Branch Number.

%macro import_xls(data=,sheet=,xls=);

proc import dbms=excelcs out=&data
server="&"; /* Name of PC files server */
port=8621; /* Port number listening on the PC server */
version='2002'; /* Excel file version */
sheet="&sheet"; /* Sheet name */
scantext=yes; /* Scan all rows data for the largest size */
usedate=yes; /* Use DATE format for date/time columns */
scantime=yes; /* Scan and identify time columns */
dbsaslabel=none; /* Leave SAS label names to be nulls */
textsize=512; /* Largest text size allowed */

%mend import_xls;
Super Contributor
Posts: 356

Re: missing underscore in Sas variable names

Have a look at the option "validvarname".
SAS Employee
Posts: 149

Re: missing underscore in Sas variable names

In certain cases, EG will allow non-default column names to be created. As the other poster suggests, you might try submitting the following code, then calling your macro program:


The default setting in EG is VALIDVARNAME=ANY.

There's a note about GETNAMES=YES changing things over to SAS names... might be worth a test as well.

Tech support could also be a good resource on this:
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation