BookmarkSubscribeRSS Feed
GrizzlyDee
Calcite | Level 5

data vehicles_info;
 set sasuser.Vehicles.xlsx;
 where make='Ford' and year='2015';
run;

proc print data=vehicles_info;
run;

 

 

With this program, I am trying to use an existing Sas table (sasuser.Vehicles.xlsx) to create a new table (vehicles_info) containing a subset of that original data. The second part of the program's goal is to generate a list report of the new table. When running the code, I've added a visual of the errors coming up in the SAS Studio log below. I have played around with the code in different ways such as omitting .xlsx from the set statement, editing the data set name, capitalizing M in make, using infile + path instead of set statement , nothing has worked. The above program, after all the tinkering, is the one with the least amount of errors. FYI - make variable is listed in the Excel table. Please assist with pointing out where I have gone wrong.

 

 

SAS error 1.PNG

 

 

1 REPLY 1
Reeza
Super User

@GrizzlyDee wrote:
 

With this program, I am trying to use an existing Sas table (sasuser.Vehicles.xlsx) to create a new table (vehicles_info) containing a subset of that original data. 

  


 

I don't believe that statement is correct. Please make sure you have correctly imported the Excel data set into SAS. There is a video recently posted on the SAS Analytics U page on how to import an Excel file. Once the file is imported correctly, you reference it with a two level name, LIBNAME.DATA_SET_NAME

 

If your dataset is called Vehicles, it would be:

 

data vehicles_info; 
 set sasuser.Vehicles;
 where make='Ford' and year='2015';
run;

The other possibility is that you have validvarnames=ANY set, which means you would refer to the dataset as:

 

data vehicles_info; 
 set sasuser.'Vehicles.xlsx'n;
 where make='Ford' and year='2015';
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 282 views
  • 0 likes
  • 2 in conversation