BookmarkSubscribeRSS Feed
mrom34
Calcite | Level 5

Hi,

I am trying to import an excel file using libname on EG. It works fine, I can connect to the file and the using a data step I can just create a table. However, it creates SAS data sets with columns names that do not comply to SAS naming conventions. I get columns with names like 'sample ID 1'. How am I suppose to use these variable names in a SAS code?

I am currently moving from display manager to EG and I am not how to solve this issue.

thanks for your help

Romain

6 REPLIES 6
Haikuo
Onyx | Level 15

Those 'sample ID 1' you have mentioned probably are just labels. The actual name is more likely to be 'sample_ID_1'. You can run proc content to confirm or just double click the column name after you have the table opened up.

Haikuo

SASKiwi
PROC Star

Try the SAS option: options validvarname = V7; It will ensure that your libname translates your Excel columns to SAS columns. The default for EG is validvarname = ANY, which produces the symptoms you are seeing. 

Reeza
Super User

You can refer to them as 'Sample ID 1'n or try changing the options to get a valid SAS var name.

mrom34
Calcite | Level 5

Thanks for your suggestion. options validvarname = V7 seems to work but it renames the columns _col0,_col1,_col2. I wish it  would just replace the blanks with underscore.

I still don't know how I can use a data set where the column name is 'Sample ID 1' ( I checked with proc content and it is actually the variable name). these data sets cannot be opened with SAS base

Reeza
Super User

In SAS BASE you then need to specify the options to use the datasets from EG. Then to reference the variable, say sample id 1 you quote it and put an n as I indicated earlier.

options validvarname=any;

data want;

set have;

sample_id1='Sample ID 1'n;

Run;

mrom34
Calcite | Level 5

Okay I think I found the solution, I just use this option: options validmemname=extend;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1293 views
  • 0 likes
  • 4 in conversation