This post was kindly contributed by SAS Users - go there to comment and to read the full post. |
SQL (Structured Query Language) is the most widely used programming language for relational databases worldwide. No other programming language produces more hits for a web search than SQL and interest is growing rapidly. In June 2010, Google showed 135 million hits versus 586 million hits in June 2020.
SQL is the programming language to handle big data. Within a very short time after its invention, SQL developed into an industry quasi-standard. The reasons behind this rapid development include the fast spread of databases, proven performance, popularity among users, and the growing relevance of analysts and programmers. Most analyst positions expect at least knowledge of basic SQL capabilities.
For analysts and programmers, SQL is attractive because once acquired, SQL skills can be applied in basically all environments from finance to healthcare, and in all systems from open source to commercial. Due to its relative independence from manufacturers (an ANSI standard), what you learn to do in SQL in Oracle can be applied to SQL in SAS.
PROC SQL in SAS is powerful and versatile. It offers myriad possibilities for working with:
- descriptive statistics
- advanced macro programming
- SAS datasets, views, or complex queries
- special application areas like integrity constraints or performance tuning
- thousands of SAS functions and SAS function calls
If you start learning PROC SQL, you will also acquire the basics of PROC FEDSQL, PROC DS2, and PROC CAS. And that will offer you a handy toolbox for SAS platforms and applications like SAS 9.4, SAS Viya, SAS Integration Studio, SAS Studio, Enterprise Guide, and many more.
Is that tempting enough to try your hand at PROC SQL? No, you want to see what you get? I will show you examples of four programs that do the same thing using PROC SQL, PROC FEDSQL, PROC DS2, and PROC CAS. I’ll keep it simple just to prove the point. But have no fear, SQL can accomplish very advanced tasks. I’ve been involved in rewriting complex SQL programs that were thousands of lines long.
Let’s use PROC SQL as a springboard. From there, choose where you want to go.
Example 1: PROC SQL
proc sql; select REGION, SUBSIDIARY, SALES from work.shoes where SALES > 750000 ; quit; |
With PROC FEDSQL, you can start working in the cloud environment of SAS Viya. Please note that PROC FEDSQL is not always 1:1 to PROC SQL as it may appear from this example.
Example 2: PROC FEDSQL
proc fedsql; select REGION, SUBSIDIARY, SALES from work.shoes where SALES > 750000 ; quit; |
DS2 allows you to speed up processing by using its built-in multi-threading capabilities.
Example 3: PROC DS2
proc DS2 ; data LEFT_RIGHT4 (overwrite=yes) ; method run(); set {select LEFT.ID, LEFT.A, RIGHT.F from work.LEFT, work.RIGHT where LEFT.ID = RIGHT.ID} ; output ; end ; enddata ; run ; quit; |
PROC CAS enables you to take advantage of SAS Cloud Analytic Services (CAS).
Example 4: PROC CAS
proc CAS; session my_CAS_session ; fedsql.execdirect query= 'select * from CASUSER.CAS_CLASS' ; Quit ; |
Notice that the SQL language elements like the SELECT statement are the same in each example. Once you have learned the basic syntax, you can use it in PROC FEDSQL, PROC DS2, and PROC CAS. And I am pretty sure, there are some more to come.
Why learn SQL? Because it’s a sustainable investment in your future. If you want to learn more about PROC SQL techniques, check out my book Advanced SQL with SAS®.
Why learn SQL? was published on SAS Users.
This post was kindly contributed by SAS Users - go there to comment and to read the full post. |