5/1/2015 1 quick and dirty excel® workbooks without dde or ods andrea zimmerman, capital one,...
TRANSCRIPT
04/18/23 1
Quick and Dirty Excel® Workbooks Without DDE or ODS
Andrea Zimmerman, Capital One, Richmond, VA
04/18/23 2
Introduction
• “Efficiency is intelligent laziness” - David Dunham
• I have avoided learning DDE, Microsoft has warned they may cut it off at any time.
• I haven’t had the time to learn ODS and the XLtagset.
04/18/23 3
PROC EXPORT The Data%let dir=C:\My Documents\2011 SAS paper\Excel\;%let file=template.xls;
proc export data=sashelp.shoes outfile= “&dir.&file” dbms=excel replace; sheet=“shoe_data”; run;
options noxsync noxwait;%sysexec &dir.&file;
This will create the initial workbook and open it.
Not Very Pretty…
04/18/23 5
Format and Build The Workbook
• Adjust column widths• AutoFilter• Freeze Panes• Hide columns• Color columns
04/18/23 6
Format and Build The Workbook
04/18/23 7
Format and Build The Workbook
• Build graphs
Note in the function that it is referencing data cells. Right now, this shows the sales for the Addis Ababa data since it is in rows 2 through 9.
04/18/23 8
Format and Build The Workbook
• Create a named range that adjusts to the amount of data.1. Click Insert.2. Highlight Name.3. Select Define…4. Name the range whatever you want (For example ShoeData).5. Type this formula in the bottom text box (assumes shoe_data is the
name of the tab): =OFFSET(shoe_data!$A$1,0,0,COUNTA(shoe_data!$A:$A),COUNTA(shoe_data!$1:$1))
6. Click OK.
04/18/23 9
Format and Build The Workbook
• Create a pivot table using the named range.1. Click Data.2. Select PivotTable and PivotChart Wizard.3. Click Next.4. Replace the value of Range with the named range created earlier.5. Click Next.6. Click Finish.7. Drag Region to be a Row Field.8. Drag Product to be a Column Field.9. Drag Sales to be a Data Item.
04/18/23 10
Format and Build The Workbook
04/18/23 11
Clear The Data and Save As…
• Once everything is set, delete the data from all tabs.
• Graphs will be empty, but the pivot tables will stay.
• Save as a name you’ll remember.• I recommend including TEMPLATE so you
remember the purpose.
04/18/23 12
The X Command• In your SAS code, before your PROC EXPORT, insert this code:
options noxwait xsync;x copy “&dir.&file” “&dir.shoe_data_&today..xls”;
• Now you have a copy of the template with today’s date as part of the name.
• The template remains unchanged.
04/18/23 13
Subset the Data
• Now we can subset the data
data womens;set sashelp.shoes;if Product=:”Women’s”;run;
04/18/23 14
Subset the Data• Now we can Export this to our workbook:
options noxwait xsync;x copy “&dir.&file” “&dir.shoe_data_&today..xls”;proc export data=womens outfile=“&dir.shoe_data_&today..xls” dbms=excel replace; sheet=”shoe_data”; run;
04/18/23 15
New Workbook
Note that this is just the Women’s products
04/18/23 16
New Workbook
You have to Refresh the Data in the pivot table when you open it.
04/18/23 18
Conclusion• Doesn’t have all the grace and finesse of DDE or ODS
and it does have some limitations.• It’s very fast to learn and master.• For the majority of my reporting needs it is more
than sufficient. • A little VBA programming or conditional formatting
can overcome any limitations that I’ve discovered. – If those are tools you already know, then this is a real time
saver.
04/18/23 19
Acknowledgement
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are registered trademarks or trademarks of their respective companies.
How to Join Us
Be an Attendee• Invest in your future• Expand your skills• Get more value to yourself and your Company• Follow us on Twitter @sesug1 #SESUG2014
How to Join Us
Be an Attendee• Invest in your future• Expand your skills• Get more value to yourself and your Company• Follow us on Twitter @sesug1 #SESUG2014