BookmarkSubscribeRSS Feed
MIsabel
Calcite | Level 5

Hi,

I want to extract some information for the table sashelp.shoes in a excel file with the bellow instruction but I also want to filter the column "Product" (second column) for the values "Sandal" and "Boot" and at the end create an excel with all the observations and the table filter by the column "Product"

 

I want to have all observations but the default view to be one with just Sandal/Boots and if i want in the Excel see the other values for that column

 

How can I update my program to have all the observations and also included the filter?

 

ods excel file="C:\Reportes\Testshoes.xlsx" options(sheet_name="Test");
ods excel options (autofilter = 'all');
proc report data=sashelp.shoes; columns _all_;
run;
ods excel close;

 

If I update proc report as the bellow line, it's only export the rows with these values, and I need to export all the lines in the excel and selected the filter with these values in the Excel.

proc report data=sashelp.shoes(where=(product="Sandal" or product='Boot'));

 

I have updated my program and now it creates the filter but it's not executed when i open the excel and I don't know how it can be executed in an automatically way by the ods option and also i would like to include in the filter more values as Boot.

 

ods excel file="C:\Reportes\Testshoes.xlsx" options(sheet_name="Test");

ods excel options (autofilter='2' autofilter_values='Sandal');
proc report data=sashelp.shoes; columns _all_; run;
ods excel close;

 

Thanks in advance for your help

3 REPLIES 3
PaigeMiller
Diamond | Level 26
proc report data=sashelp.shoes(where=(product="Sandal" or product='Boot'));
--
Paige Miller
Reeza
Super User
Do you want your table to have all observations but the default view to be one with just Sandal/Boots but you can add back in the others?

or

Do you want a table exported with just Sandal/Boots?
RichardDeVen
Barite | Level 11

ODS EXCEL has no mechanism nor options settings that let you preselect the filter values for an autofilter column.

 

In EXCEL you would write VBA code to programmatically set the current 'checked' values in the drop downlist.

 

Example:

' VBA code
Dim items(1 to 2) as String
items(1) = "Sandal" items(2) = "Boot" ActiveSheet.ListObjects("Table1").range.AutoFilter Field:=2, Criteria1:=items, Operator:=xlFilterValues

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 3463 views
  • 0 likes
  • 4 in conversation