全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 学习笔记1.0
758 0
2012-09-18
今天找到一篇09年SUGI上讲PROC TRANSPOSE 的入门文章

Paper 060-2009:

Zirbel, Douglas

Learn the Basics of PROC TRANSPOSE



Quick Reference Sheet – Proc Transpose
·  Proc Transpose changes multiple values in rows (for a column) into columns, and can also change multiple
columns’ values into multiple rows values for a single column
·  It knows how many columns to create for your output file based on the maximum number of values in a column
to be transposed (to do this with a Data Step is tedious)
·  ID statement names the column in the input file whose row values provide the column names in the output file.
There should only be one variable in an ID statement. Also, the column used for the ID statement cannot have
any duplicate values. For example, Mr. Black and Mr. White cannot both have cats. If this is the case, one
solution is to create a different input dataset by using Proc Means to sum the values so that there is only one row
for each pet. What if the values of ID are numeric and can’t be used as SAS column names? Then use the
prefix= option with the ID statement to create variables like “mile140”, “mile150”, etc.
·  VAR statement specifies which variables’ values are to be transposed; can be character and/or numeric
variables; if VAR is omitted, Transpose transposes all numeric vars
·  BY statement names row-identification variable(s) whose values are not transposed; it requires a preliminary
Proc Sort
·  Transpose includes some default variables in the output dataset such as _NAME_, _LABEL_. You can override
them with statement options or drop them in a dataset drop option
·  Prefix option provides a prefix to the transposed column names instead of COL1, COL2, etc
·  Name option provides the name for an output file column which tells which input variables were transposed
·  Transposing two times – it is sometimes necessary to transpose an input file two or more times, then merge
the output files together due to the only-1-ID-per-transpose limitation.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群