码迷,mamicode.com
首页 > 其他好文 > 详细

sas transpose过程

时间:2014-11-28 20:07:22      阅读:583      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

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. ??

bubuko.com,布布扣

 

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

_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;

改变前后效果如下

bubuko.com,布布扣

 

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!

 

 

 

 

 

sas transpose过程

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/yican/p/3824139.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!