Newbie -- Set and Where Statement problems

Reply
New Contributor
Posts: 4

Newbie -- Set and Where Statement problems

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

 

 

Super User
Posts: 18,997

Re: Newbie -- Set and Where Statement problems


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;
Ask a Question
Discussion stats
  • 1 reply
  • 97 views
  • 0 likes
  • 2 in conversation