philihpAboutPGPLightning

Counting distinct variables in SQL with SAS

Philihp Busby,0 min read

One way to get the count of distinct variables, which works in most flavors of SQL, is to use a subquery. For instance, in Oracle this is:

SELECT count(SELECT DISTINCT foo FROM table) FROM dual

In SAS, using PROC SQL, you can do that too, but you can also simply do this:

SELECT count(distinct foo) FROM table

GitHub · Bluesky · LinkedIn · Instagram · KeybaseRSS

Built from 8f0906ac CC BY 4.0 — with love from San Francisco.