BookmarkSubscribeRSS Feed
yangx
Obsidian | Level 7

Hello,

 

When I used proc import to import an excel file, I got different variable names for SAS version 9.2 and 9.4.

Below is the program:

proc import datafile="copy.xls" out=othlab1 dbms=xls replace;
getnames=yes;
datarow = 2;
run;

In the excel file one column has "HbA1c (fraction)" as label, when I ran the program using SAS9.2, I got "NOTE: variable name change: HbA1c (fraction) -> VAR19"; if I ran the program using sas9.4, I got  "NOTE:    Variable Name Change.  HbA1c (fraction) -> HbA1c__fraction_. I know bracket is not valid SAS variable name, it should change to VAR followed by a number, but whey does SAS9.4 interpret this as a different way? Thanks.

 

xiumei

 

4 REPLIES 4
Kurt_Bremser
Super User

It seems that SAS 9.4 tries to preserve more of the original variable name when converting to a valid SAS name.

If you want to have consistent control over data import, do not use the Excel format; instead save your data as a csv file and import that with a data step where you set variable names.

Tom
Super User Tom
Super User

SAS made major upgrades in the support of Excel format files. I suspect that this includes changes how it renames the illegal column names.

 

What happens if you try the same with the system option VALIDVARNAME set to ANY.

yangx
Obsidian | Level 7

Hello,

Thanks for your quick reply. I tried to use system option VALIDVARNAME=ANY, both versions produced the same variable names.

 

Xiumei

 

ballardw
Super User

I'm feeling a little snarky today so I'll say this is yet another reason not to use Excel for data interchange and not to rely on proc import for repetitive tasks.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 1735 views
  • 3 likes
  • 4 in conversation