I know if i want to find how many distinct a, I can use count (distinct a)
Now I need find how many different combination of a and b.
What I should do?
Another option:
select count(distinct catx('.',sex,age) ) as n_sex_by_age from have ;
If you create two temporary tables consisting of one with just A and the other with Just B, then join them to get the Cartesian product (no where clause or INNER JOIN) and then do a SELECT COUNT DISTINCT on the Cartesian product, I think that should give you the number you want.
Some thing like this but check my syntax:
PROC SQL;
CREATE TABLE A_TAB as SELECT DISTINCT A FROM Source_Table;
CREATE TABLE B_TAB as SELECT DISTINCT B FROM Source_Table;
CREATE TABLE A_B_TAB as SELECT * FROM A_TAB, B_TAB;
SELECT COUNT(DISTINCT *) FROM A_B_TAB;
QUIT;
Jim
select count(*) from (select distinct a, b from HAVE) ;
Another option:
select count(distinct catx('.',sex,age) ) as n_sex_by_age from have ;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.