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 ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.