How to consider different from concatenation / crossing of two variables in SAS Proc Sql?

I know that in teradata or other sql platforms you can find an account different from a combination of variables by doing:

select counter (excellent x1 || x2) from db.table

And this will give all the unique combinations of pairs x1, x2.

This syntax, however, does not work in proc sql.

Is there any way to execute such an account in proc sql?

Thank.

+4
source share
2 answers

This syntax works great in PROC SQL.

proc sql;
  select count(distinct name||sex)
    from sashelp.class;
quit;

If the fields are numeric, you must put them in a character (using put) or use cateither one of his siblings, who are happy to accept either numeric or characters.

proc sql;
  select count(distinct cats(age,sex))
    from sashelp.class;
quit;
+9
source

, "", "" . , , :

DATA TEST;
    INPUT (X1 X2) (:$8.);
    CARDS;
A B
B A
C D
C D
;

PROC SQL;
    SELECT COUNT(*) AS TOTAL, COUNT(DISTINCT CATS(X1,X2)) AS PERMUTATION, 
        COUNT(DISTINCT CATS(IFC(X1<=X2,X1,X2),IFC(X1>X2,X1,X2))) AS  COMBINATION
    FROM TEST;
QUIT;
+2

All Articles