SUBJID | AGERP | sex | arm |
01-S001 | 30 to 39 years | Female | 1 |
01-S003 | 40 to 49 years | Female | 1 |
01-S005 | 60 years | Male | 1 |
01-S007 | 60 years | Male | 1 |
01-S009 | 40 to 49 years | Female | 1 |
01-S011 | 60 years | Female | 1 |
01-S013 | 60 years | Male | 1 |
02-S001 | 40 to 49 years | Female | 1 |
02-S003 | 50 to 59 years | Female | 1 |
02-S005 | 50 to 59 years | Female | 1 |
03-S002 | 60 years | Female | 1 |
03-S004 | 40 to 49 years | Female | 1 |
03-S006 | 50 to 59 years | Female | 1 |
03-S008 | 30 to 39 years | Female | 1 |
03-S010 | 50 to 59 years | Female | 1 |
03-S012 | 60 years | Female | 1 |
03-S014 | 50 to 59 years | Male | 1 |
03-S016 | 50 to 59 years | Female | 1 |
03-S018 | 30 to 39 years | Male | 1 |
03-S020 | 40 to 49 years | Male | 1 |
01-S002 | 60 years | Female | 2 |
01-S004 | 60 years | Male | 2 |
01-S006 | 60 years | Female | 2 |
01-S008 | 40 to 49 years | Male | 2 |
01-S010 | 50 to 59 years | Male | 2 |
01-S012 | 40 to 49 years | Female | 2 |
01-S014 | 50 to 59 years | Female | 2 |
02-S002 | 60 years | Male | 2 |
02-S004 | 60 years | Male | 2 |
03-S001 | 50 to 59 years | Female | 2 |
03-S003 | 40 to 49 years | Male | 2 |
03-S005 | 60 years | Male | 2 |
03-S007 | 50 to 59 years | Female | 2 |
03-S009 | 40 to 49 years | Male | 2 |
03-S011 | 50 to 59 years | Female | 2 |
03-S013 | 40 to 49 years | Female | 2 |
03-S015 | 40 to 49 years | Female | 2 |
03-S017 | 30 to 39 years | Female | 2 |
03-S019 | 40 to 49 years | Male | 2 |
03-S021 | 60 years | Female | 2 |
想通過sql建立一個table變成以下結(jié)果
age/sex | group | count |
30 to 39 years | 1 | 3 |
40 to 49 years | 1 | 5 |
50 to 59 years | 1 | 6 |
60 years | 1 | 6 |
30 to 39 years | 2 | 1 |
40 to 49 years | 2 | 7 |
50 to 59 years | 2 | 5 |
60 years | 2 | 7 |
Male | 1 | 6 |
Female | 1 | 14 |
Male | 2 | 9 |
Female | 2 | 11 |
我的想法是:
proc sql;
create table age_group as select arm,count(select AGERP,arm,count(SUBJID) from origin_1 group by AGERP,arm),count(select SEX,arm,count(SUBJID) from origin_1 group by SEX,arm) from origin_1 group by arm;
quit;
但是會報錯。
我知道可以分別對AGERP和sex建立兩個table,然后set到一起,但是我想知道能不能一次性做到,畢竟我覺得sql很強(qiáng)大!