Your SlideShare is downloading. ×
Proc SQL in SAS Enterprise Guide 4.3
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Proc SQL in SAS Enterprise Guide 4.3

5,789
views

Published on

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,789
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
71
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PROC SQLIN SAS ENTERPRISEGUIDE 4.3Mark TabladilloDecember 12, 2011
  • 2. About MarkTab2  Consultant: Data Mining Architect  SAS since 1991  Microsoft MVP this year  Presenting and Publishing since 1998  Data Mining Blog http://www.marktab.net  Twitter @marktabnet (C) 2011 Mark Tabladillo
  • 3. Purpose3  Provide basic vocabulary and pointers for absolute beginners  Challenge intermediate-to-advanced users (C) 2011 Mark Tabladillo
  • 4. Outline4  Basics on Enterprise Guide 4.3  PROC SQL  SQL Clauses  Order of Operations – Best Practices  Joins – Best Practices  Macro variables (C) 2011 Mark Tabladillo
  • 5. (C) 2011 Mark Tabladillo 5BASICS ON SASENTERPRISE GUIDE4.3
  • 6. About SAS Enterprise Guide6 4.3  Shipped July 2011  New features include  New Program Editor with Autocomplete and Integrated Syntax Help  Explicit SQL Pass-through Option  Macro Variables for Conditional Processing http://support.sas.com/documentation/cdl/en/whatsnew/62580/HTML/default/viewer.htm#egwhatsnew43 .htm (C) 2011 Mark Tabladillo
  • 7. SAS Enterprise Guide 4.37 Tutorial  http://support.sas.com/documentation/onlinedoc/guide/tut43/en/ (C) 2011 Mark Tabladillo
  • 8. Tutorial Topics8 (C) 2011 Mark Tabladillo
  • 9. Enterprise Guide is ClientSoftware SAS on Windows SAS on Mainframe SAS on UNIX SAS Enterprise Guide (C) 2011 Mark Tabladillo 9
  • 10. The SAS Intelligence PlatformArchitecture Enterprise Guide is fully integrated with the servers in the SAS 9 environment. SAS Metadata Server SAS OLAP Server SAS Enterprise Guide SAS Stored Process Server SAS Workspace Server (C) 2011 Mark Tabladillo 10
  • 11. (C) 2011 Mark Tabladillo 11PROC SQLSQL Clauses
  • 12. Important in Enterprise Guide12 (C) 2011 Mark Tabladillo
  • 13. Autocompletion13 (C) 2011 Mark Tabladillo
  • 14. Typical SQL Statement – Six14 Clauses SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 15. How many clauses are15 required? SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 16. What is an example of a16 column? SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 17. What is an example of a table?17 SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 18. What is an example of an18 expression? SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 19. What does DESC mean?19 SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 20. Mnemonic20 SELECT column-1 <, ...column-n> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; SO FEW WORKERS GO HOME ON time! (C) 2011 Mark Tabladillo
  • 21. (C) 2011 Mark Tabladillo 21PROC SQLOrder of Operations – Best Practices
  • 22. Order of Operations22  SQL is a declarative language  You declare the final product  Then, the SQL interpreter decides how to create that final product (C) 2011 Mark Tabladillo
  • 23. Why try for one SELECT23 statement?  SQL is a declarative language  You declare the final product  Then, the SQL interpreter decides how to create that final product (C) 2011 Mark Tabladillo
  • 24. Order of Operations24 5 SELECT column-1 <, ...column-n> 1 FROM table-1|view-1<, ...table-n|view-n> 2 <WHERE expression> 3 <GROUP BY column-1 <, ....column-n>> 4 <HAVING expression> 6 <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 25. Best Practices?25 5 SELECT column-1 <, ...column-n> 1 FROM table-1|view-1<, ...table-n|view-n> 2 <WHERE expression> 3 <GROUP BY column-1 <, ....column-n>> 4 <HAVING expression> 6 <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 26. (C) 2011 Mark Tabladillo 26PROC SQLJoins – Best Practices
  • 27. Joins27 Type Description LEFT JOIN One to Many RIGHT JOIN Many to One FULL JOIN Many to Many, with Missing CROSS JOIN Product UNION JOIN Concatenation NATURAL JOIN Conservative Matching Recommended: Sams Teach Yourself SQL in 10 Minutes (3rd Edition) by Ben Forta Reference: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/def ault/viewer.htm#a002473691.htm (C) 2011 Mark Tabladillo
  • 28. Think Through Join Sources28  SAS can join  SAS  Excel  Access  Oracle  Mainframe  Text Files (C) 2011 Mark Tabladillo
  • 29. Best Practice Rules29  Typed data is better than non-typed  Subset better than the whole  Native SQL better than SAS SQL  In-memory data is faster than disk data  Close to the server is better than far away – subset before moving  SAS sources are better than not (C) 2011 Mark Tabladillo
  • 30. (C) 2011 Mark Tabladillo 30PROC SQLMacro Variables
  • 31. PROC SQL Makes Macro31 Variables SELECT column-1 <, ...column-n> INTO macro-variable-specification < , ... macro-variable-specification> FROM table-1|view-1<, ...table-n|view-n> <WHERE expression> <GROUP BY column-1 <, ....column-n>> <HAVING expression> <ORDER BY column-1 <DESC><, ... Column-n>>; quit; (C) 2011 Mark Tabladillo
  • 32. What is a Macro Variable?32  Text Variable  Stores Information in Memory  Typically scoped to Global  Dynamically Generated  Useful as a prequel to a PROC SQL statement  Useful as an Enterprise Guide 4.3 Condition (C) 2011 Mark Tabladillo
  • 33. Macro Variables as Conditions33 (C) 2011 Mark Tabladillo
  • 34. Defining a Macro Condition34 (C) 2011 Mark Tabladillo
  • 35. Process Flow Conditions35 (C) 2011 Mark Tabladillo
  • 36. Recommended36  http://support.sas.com  Books  Sams Teach Yourself SQL in 10 Minutes (3rd Edition) by Ben Forta  The Little SAS Book for Enterprise Guide 4.2 by Susan J. Slaughter and Lora D. Delwiche  Professional SAS Programmers Pocket Reference Sixth Edition by Rick Aster (C) 2011 Mark Tabladillo
  • 37. Conclusion37  Enterprise Guide 4.3 allows for simple through advanced processing with PROC SQL  Many resources available:  FreeSAS tutorials  Books  People (C) 2011 Mark Tabladillo