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

Hi, I am very new to SAS and trying to read an xls file and using the following code.

libname orionxls 'sales.xls';

data work.subset2;

set orionxls.'Australia$'n;

where Job_Title contains 'Rep';

keep First_Name Last_Name Salary Job_Title Hire_Date;

label Job_Title='Sales Title' Hire_Date='Date Hired';

format Salary comma10. Hire_Date weekdate.; run; 

Code is not functioning because in excel file column name is Job Title (with blank space).

My question is how to write the column name with blank space in such type of code?

Thanks in advance

Best Regards

Dani

1 ACCEPTED SOLUTION

Accepted Solutions
MichelleHomes
Meteorite | Level 14

I assume you are trying to run the program in SAS Enterprise Guide? If so, you will need to change the columns that have a space in it to be written as named literal variables. So instead of Job_Title, it will be "Job Title"n which treats the string as a variable. Don't forget the n as this tells the compiler to treat it as the name literal rather than a string.

The other columns: First_Name, Last_Name, Hire_Date in all the other statements will need to be updated too.

Kind Regards,

Michelle

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com

View solution in original post

5 REPLIES 5
MichelleHomes
Meteorite | Level 14

I assume you are trying to run the program in SAS Enterprise Guide? If so, you will need to change the columns that have a space in it to be written as named literal variables. So instead of Job_Title, it will be "Job Title"n which treats the string as a variable. Don't forget the n as this tells the compiler to treat it as the name literal rather than a string.

The other columns: First_Name, Last_Name, Hire_Date in all the other statements will need to be updated too.

Kind Regards,

Michelle

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
danimian
Calcite | Level 5

Yes, it is working now.

Thanks a lot.


MichelleHomes
Meteorite | Level 14

No problem. I teach the SAS Programming 1 course for SAS Education in Australia and am familiar with this piece of code and the issue of running it in Enterprise Guide. 🙂

FYI, it's due to a SAS System option, validvarname having different values in Foundation SAS and SAS Enterprise Guide.

Glad to hear your code is running now.

Kind Regards,

Michelle

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
danimian
Calcite | Level 5

Many thanks for more details and quick help.

Right, this code is from Prog. 1 examples.

I am Newbie-SAS-Programmer and in high learning mode Smiley Happy.

Best Regards

TomKari
Onyx | Level 15

Well, you're in the right place...Michelle has forgotten more about Enterprise Guide than most of us know...

Keep asking questions!

  Tom

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2426 views
  • 1 like
  • 3 in conversation