Tag: sql

Unexpected results from missing values with PROC SQL

SAS SQL handles missing values differently than the ANSI standard for SQL. PROC SQL follows the SAS convention for handling missing values: numerical missing values are always interpreted as less or smaller than all nonmissing values. My first blog showed that missing values can be troublemakers in non-grouped descriptive statistics. […]

Unexpected results from missing values with PROC SQL was published on SAS Users.

Why learn SQL?

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 […]

Why learn SQL? was published on SAS Users.

CAS-Action! Executing SQL in SAS Viya

SQL is an important language for any programmer working with data. In SAS Cloud Analytic Services (CAS) you can execute SQL queries using the fedSQL.execDirect CAS action! Welcome back to my SAS Users blog series CAS Action! – a series on fundamentals. I’ve broken the series into logical, consumable parts. […]

CAS-Action! Executing SQL in SAS Viya was published on SAS Users.

Fuzzy Matching

The term “fuzzy matching” describes a method of comparing two strings that might have slight differences, such as misspelling or a middle initial in a name included or not included. One of my favorite functions to compare the “closeness” of two strings is the SPEDIS (spelling distance) function. Have you […]

Fuzzy Matching was published on SAS Users.

Learn to Love SAS LIKE

In honor of Valentine’s day, we thought it would be fitting to present an excerpt from a paper about the LIKE operator because when you like something a lot, it may lead to love! If you want more, you can read the full paper “Like, Learn to Love SAS® Like” […]

Learn to Love SAS LIKE was published on SAS Users.

Expand Your SAS Knowledge by Learning PROC SQL

One great thing about being a SAS programmer is that you never run out of new things to learn. SAS often gives us a variety of methods to produce the same result. One good example of this is the DATA step and PROC SQL, both of which manipulate data. The […]

Expand Your SAS Knowledge by Learning PROC SQL was published on SAS Users.

Reusing calculated columns in Netezza and SAS queries

Netezza and SAS allow a query to reference a calculated column by name in the SELECT, WHERE, and ORDER BY clauses. Based on the DRY principle, this reduces code and makes code easier to read and maintain.

Some people call calculated columns derived or computed columns.

In Microsoft SQL Server, SQLite, and other RDBMSs you cannot exactly do this: a workaround is to reference a subquery or view. In Microsoft SQL Server, you can also define a computed column on a table.

Below is an example tested with Netezza 7.2. Notice height_m is used in the SELECT clause, and bmi is used in the WHERE and ORDER BY clauses.

Read more »

For more posts like this, see Heuristic Andrew.

Convert CHAR to NUM in PROC SQL

Use TO_NUMBER function in PROC SQL. proc sql;   connect to oracle (user=xxx orapw=yyy path=”@zzz”);     create table temp as       select * from connection to oracle    &nb…