SAS数据处理
答案:1 悬赏:30 手机版
解决时间 2021-01-25 04:50
- 提问者网友:缘字诀
- 2021-01-24 11:13
SAS数据处理
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-01-24 12:35
DATA CHENGJI1;
INPUT NAME $ SEX $ MATH CHN GROUP;
CARDS;
李明 男 92 98 1
张红艺 女 89 106 1
王思明 男 86 90 1
;
RUN;
DATA CHENGJI2;
INPUT NAME $ SEX $ MATH CHN GROUP;
CARDS;
张聪 男 95 92 2
刘颖 女 98 101 2
高红 女 91 92 2
;
RUN;
DATA CHENGJI3;
INPUT NAME $ SEX $ MATH CHN GROUP;
CARDS;
赵强 男 93 99 3
李云芳 女 96 102 3
周闪 男 88 98 3
;
RUN;
*第二步;
DATA CHENGJI0;
SET CHENGJI1 CHENGJI2 CHENGJI3;
RUN;
*第三步;
DATA CHENGJI;
SET CHENGJI0;
AVG=MEAN(MATH,CHN);
RUN;
PROC SORT;
BY AVG;
RUN;
*第四步;
DATA MATH90;
SET CHENGJI0;
WHERe MATH>90;
RUN;
*第五步;
PROC SORT DATA=CHENGJI(KEEP=NAME GROUP AVG) OUT=LAST ;
BY GROUP AVG;
RUN;
DATA LAST;
SET LAST;
BY GROUP AVG;
IF FIRST.GROUP;
RUN;
*第六步;
PROC SORT DATA=CHENGJI0 OUT=MATH;
BY SEX;
RUN;
DATA MATH(KEEP=SEX AVG SUM_ALL);
SET MATH END=T;
BY SEX;
IF FIRST.SEX THEN DO;
I=0;
M=0;
END;
M+MATH;
I+1;
AVG=M/I;
J+1;
TOT+MATH;
IF LAST.SEX;
IF T THEN SUM_ALL=TOT;
RUN;
*第七步;
PROC SUMMARY DATA=CHENGJI0 NWAY;
VAR MATH;
OUTPUT OUT=A(DROP=_TYPE_ RENAME=(_FREQ_=N)) SUM=TOT;
RUN;
DATA DIF;
IF _N_=1 THEN SET A;
SET CHENGJI0;
AVG=TOT/N;
DIFF=AVG-MATH;
DROP TOT N;
RUN;
*第八步;
DATA EN;
INPUT EN @@;
CARDS;
80 84 85 86 82 87 96 75 52
;
RUN;
DATA ALL;
SET CHENGJI0;
SET EN;
RUN;
楼上这位是大牛,多向他学习学习
INPUT NAME $ SEX $ MATH CHN GROUP;
CARDS;
李明 男 92 98 1
张红艺 女 89 106 1
王思明 男 86 90 1
;
RUN;
DATA CHENGJI2;
INPUT NAME $ SEX $ MATH CHN GROUP;
CARDS;
张聪 男 95 92 2
刘颖 女 98 101 2
高红 女 91 92 2
;
RUN;
DATA CHENGJI3;
INPUT NAME $ SEX $ MATH CHN GROUP;
CARDS;
赵强 男 93 99 3
李云芳 女 96 102 3
周闪 男 88 98 3
;
RUN;
*第二步;
DATA CHENGJI0;
SET CHENGJI1 CHENGJI2 CHENGJI3;
RUN;
*第三步;
DATA CHENGJI;
SET CHENGJI0;
AVG=MEAN(MATH,CHN);
RUN;
PROC SORT;
BY AVG;
RUN;
*第四步;
DATA MATH90;
SET CHENGJI0;
WHERe MATH>90;
RUN;
*第五步;
PROC SORT DATA=CHENGJI(KEEP=NAME GROUP AVG) OUT=LAST ;
BY GROUP AVG;
RUN;
DATA LAST;
SET LAST;
BY GROUP AVG;
IF FIRST.GROUP;
RUN;
*第六步;
PROC SORT DATA=CHENGJI0 OUT=MATH;
BY SEX;
RUN;
DATA MATH(KEEP=SEX AVG SUM_ALL);
SET MATH END=T;
BY SEX;
IF FIRST.SEX THEN DO;
I=0;
M=0;
END;
M+MATH;
I+1;
AVG=M/I;
J+1;
TOT+MATH;
IF LAST.SEX;
IF T THEN SUM_ALL=TOT;
RUN;
*第七步;
PROC SUMMARY DATA=CHENGJI0 NWAY;
VAR MATH;
OUTPUT OUT=A(DROP=_TYPE_ RENAME=(_FREQ_=N)) SUM=TOT;
RUN;
DATA DIF;
IF _N_=1 THEN SET A;
SET CHENGJI0;
AVG=TOT/N;
DIFF=AVG-MATH;
DROP TOT N;
RUN;
*第八步;
DATA EN;
INPUT EN @@;
CARDS;
80 84 85 86 82 87 96 75 52
;
RUN;
DATA ALL;
SET CHENGJI0;
SET EN;
RUN;
楼上这位是大牛,多向他学习学习
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯