Tag: sql

First One In Gets the Win

Yikes, it’s been a while since the last update! So I will try to keep this one short and useful. Most everybody knows there are essentially two ways for tables to be merged in SAS: using the merge statement in the data step and using a join in SQL. …

First One In Gets the Win

Yikes, it’s been a while since the last update! So I will try to keep this one short and useful. Most everybody knows there are essentially two ways for tables to be merged in SAS: using the merge statement in the data step and using a join in SQL. …

SQL tip – Inner join shorthand with USING

We write a LOT of SQL here and although SQL is a powerful database language, it can be tedious. So here is one tip for shortening all that typing. Typical join sytax: select some_columns from one_table join another_table on one_table.column_1 = another_table.column_1 and one_table.column_2=another_table.column_2 where some_column > someother_column ; Not too bad, right? In order for […]

NOTE: Using the ANY and ALL Operators in PROC SQL

Let me put my cards on the table before we start: I had never heard of the ANY and ALL operators in PROC SQL before I spotted David Shannon’s tweet this evening. The ANY and ALL operators are PROC SQL operators which can be used to compare the result o…

Create Oracle Tables

libname oradb Oracle User=orauser Password=xxxxxxx Path=”@orapth”; proc sql;&nbsp &nbsp &nbsp create table oradb.dsn as&nbsp &nbsp &nbsp select * from temp;quit;run;proc append base=oradb.dsn data=temp1 force;run;

NOTE: DATA Step’s _N_ is PROC SQL’s Monotonic

I’ve made a few posts over the last few months about SQL (particularly its use within Enterprise Guide). One of my unstated issues with SQL is the inability to do the equivalent of DATA step’s _N_ to count unique rows. The ability to add a sequence num…

NOTE: More on sorting and SQL

Further to my recent post on telling SAS that your data is pre-sorted, it’s worth mentioning the SORTVALIDATE system option. This yes/no option tells SAS whether the SORT procedure should verify if a data set is sorted according to the variab…