sas transpose过程

transpose基本语法

Note: If output-data-set does not exist, PROC TRANSPOSE creates it by using the
DATA n naming convention. 􀀀
Note: If you omit the VAR statement, the TRANSPOSE procedure transposes all of
the numeric variables in the input data set that are not listed in another statement. 􀀀
Note: You must list character variables in a VAR statement if you want to transpose
them. 􀀀

 

被转置后数据集中的默认变量名时啥?

_NAME_:is the default name of the variable that PROC TRANSPOSE creates to identify the source of the values in each observation in the output data set

This variable is a character variable whose values are the names of the variables that are transposed from the input data set

默认标签为:NAME OF FORMER VARIABLE

col1-coln:其余的列都是默认命名

 

如何改变默认变量名?

The NAME= option specifies a name for the _NAME_ variable

The PREFIX= option specifies a prefix to use in constructing names for transposed variables in the output data set

proc transpose data=sasuser.ctargets
  out=work.ctarget2
  name=Month
  prefix=Ctarget;
run;

改变前后效果如下

 

by statement对转置数据集进行分组

For each BY group, PROC TRANSPOSE creates one observation for each variable that it transposes. The BY variable itself is not transposed

我的理解:转置后的数据集第一列的值全都是以前的变量名,如果用by后,by变量并不会进行转置,而是在第一列作为分组变量出现,(考虑单个by的情况)第二列才是_NAME_列

对每一个by组都会将以前的变量列出来一遍

 

var statement

var中的变量是需要进行转置的变量,声明哪些就只会对哪些进行转置,其他don't care!

 

 

 

 

 

posted @ 2014-11-28 19:21  暴走的豆浆  阅读(3130)  评论(0编辑  收藏  举报