I am looking for a best way to process my data and export to excel so the users will have flexibility to filter and get the summary counts.
So far what I have done in my SAS program is: I applied all the filters and the business rules and created a line list. Using Excel engine I wrote this line list to a pre-existing Excel template where I created a pivot table with all the row and column counts and grand total along with standard bar graphs. When I run this every afternoon the line list is overwriting the existing Excel table so my pivot table is not refreshing with new data. Running SAS on local machine (windows environment). Open to any suggestions to give flexibility to my users to filter by start date, end date, dept. etc and get the overall counts.
Thank you
I found a solution...
option 1: Creating table using libname BL xlsx file="c:\temp\temp.xlsx"; - this method will not work
option 2: Only ODS will work..
ods excel file="c:\temp\temp.xlsx" options(sheet_name="shoe_report");
proc print data=sashelp.shoes;
run;
ods excel close;
Followed this link and was able to create pivot table. Very helpful: https://blogs.sas.com/content/sgf/2015/03/27/using-sas-to-add-pivottables-to-your-excel-workbook/. But have some issues with chart creation
Yes, I created the pivot table and charts from excel table instead of the range. Every day when I updated my line list( excel table) that table is dropped and recreated that's when the link is broken between the pivot table and excel table as a result its not getting refreshed, even when I checked the refresh data when opening the file. May be appending the rows might work but I cannot use append because some of my previous data will be updated so I need to write the complete table every day.
How do you create the pivot table? ODS or DDE or just proc export?
I found a solution...
option 1: Creating table using libname BL xlsx file="c:\temp\temp.xlsx"; - this method will not work
option 2: Only ODS will work..
ods excel file="c:\temp\temp.xlsx" options(sheet_name="shoe_report");
proc print data=sashelp.shoes;
run;
ods excel close;
Followed this link and was able to create pivot table. Very helpful: https://blogs.sas.com/content/sgf/2015/03/27/using-sas-to-add-pivottables-to-your-excel-workbook/. But have some issues with chart creation
While using the libname excel engine statement (option 1 in my post), I am writing to a preexisitng Excel template where the pivot table and pivot chart are locally created in Excel template using the line list exported from SAS. Next day when I run my SAS program new line list is over writting the exisitng line list in excel( which is nothing but the Excel table) the source of local pivot table.
By using option 2, Pivot table is created in the SAS program with all the dimentions of columns and rows and then exported to the Excel.
Hope this clarifies your question.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.