5/1/2015 1 quick and dirty excel® workbooks without dde or ods andrea zimmerman, capital one,...

21
06/23/22 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

Upload: garret-newsum

Post on 15-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 1

Quick and Dirty Excel® Workbooks Without DDE or ODS

Andrea Zimmerman, Capital One, Richmond, VA

Page 2: 5/1/2015 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.

Page 3: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 4: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

Not Very Pretty…

Page 5: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 5

Format and Build The Workbook

• Adjust column widths• AutoFilter• Freeze Panes• Hide columns• Color columns

Page 6: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 6

Format and Build The Workbook

Page 7: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 8: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 9: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 10: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 10

Format and Build The Workbook

Page 11: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 12: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 13: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 13

Subset the Data

• Now we can subset the data

data womens;set sashelp.shoes;if Product=:”Women’s”;run;

Page 14: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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;

Page 15: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 15

New Workbook

Note that this is just the Women’s products

Page 16: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

04/18/23 16

New Workbook

You have to Refresh the Data in the pivot table when you open it.

Page 17: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 18: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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.

Page 19: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA
Page 20: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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

Page 21: 5/1/2015 1 Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA

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