sas - SAS 人口统计表
问题描述
我一直在尝试创建一个像下面这样的人口统计表,但我似乎无法附加不同的表。请告知我可以在代码中进行调整的位置。
Group A Group B
chort 1 cohort 2 cohort 3 subtotal cohort 4 cohort 5 cohort 6 subtotal
Age
n
mean
sd
median
min
Gender
n
female
male
Race
n
white
asian
hispanic
black
我的代码:
PROC FORMAT;
value content
1=' '
2='Age'
3='Gender'
4='Race'
value sex
1=' n'
2=' female'
3=' male';
value race
1=' n'
2=' white'
3=' asian'
4=' hispanic'
5=' black';
value stat
1=' n'
2=' Mean'
3=' Std. Dev.'
4=' Median'
5=' Minimum';
RUN;
DATA testtest;
SET test.test(keep = id group cohort age gender race);
RUN;
data tottest;
set testtest;
output;
if prxmatch('m/COHORT 1|COHORT 2|COHORT 3/oi', cohort) then do;
cohort='Subtotal';
output;
end;
if prxmatch('m/COHORT 4|COHORT 5|COHORT 6/oi', cohort) then do;
cohort='Subtotal';
output;
end;
run;
data count;
if 0 then set testtest nobs=npats;
call symput('npats',put(npats,1.));
stop;
run;
proc freq data=tottest;
tables cohort /out=patk0 noprint;
tables cohort*sex /out=sex0 noprint;
tables cohort*race /out=race0 noprint;
run;
PROC MEANS DATA = testtest n mean std min median;
class cohort;
VAR age;
RUN;
我知道我必须将其转置并在报告中输出。但在我这样做之前,我如何从我的 proc 方法、proc freq 等中获取变量?
解决方案
推荐阅读
- unit-testing - cypress waitUntil 超时重试
- commit - 在 perforce 中将 PDF 文件推送到 ML 会导致独家结帐并在 chengelist 中标记为分支
- repository - Bitbucket 未从 Sourcetree 更新
- java - 方法interpretBMI(double) 未定义Main 类型
- revit-api - 如何检索选定房间的墙壁?
- java - 如何在 JPA Criteria API 上正确使用 JOIN
- python - 如何在 Python 中使用 PyWavelets 和 numpy 接收小波包变换后的值列表?
- sql - SQL查询传入和传出的股票,第一个和最后一个
- java - SnakeYAML - 文档和项目主页在哪里(它还活着)?
- android - Flutter 错误:非活动 InputConnection 上的 getSelectedText。在接受输入的同时获得