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!

 

 

 

 

 

转载于:https://www.cnblogs.com/yican/p/3824139.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值