sas20210521
/*1.proc语句:将要运行的SAS过程*/
data a;
set sashelp.class;
proc print;
/*先排序才能分组打印*/
proc sort data=a;
by sex;
proc print data=a;
/*对哪些变量生效*/
var name age height;
by sex;
run;
/*矫正平方和css*/
proc means data=sashelp.class css;
var height;
run;
proc means data=sashelp.class;
run;
/*规定代替观测序号的变量*/
data class;
set sashelp.class;
proc print;
id name;
run;
/*转置语句,只转置数*/
proc transpose data=sashelp.class out=a;
id name;
proc print data=a;
run;
/*应用class语句*/
proc means data=sashelp.class;
var weight height;
class sex;
output out=a mean=w_m h_m;
run;
/**/
proc means data=sashelp.class;
var weight height;
class sex;
output out=a mean=w_m h_m;
proc print data=a;
run;
/*class替换为by*/
data a;
set sashelp.class;
proc sort data=a;
by sex;
proc print data=a;
var name age height;
by sex;
proc means data=a min css;
var height;
run;
/*降序排列descending date默认升序不加前缀*/
proc sort data=whq.stk000001 out=sort;
by descending clpr date;
data a;
set sort;
keep stkcd lstknm date oppr clpr;
proc print data=a (obs=5);
run;
/*转置*/
proc transpose data=sashelp.class out=student;
id name;
var sex age height weight;
proc print data=student noobs;
run;

浙公网安备 33010602011771号