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

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!

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
  • 5 replies
  • 1479 views
  • 1 like
  • 3 in conversation