Zirbel, Douglas | ||
| ||
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.


雷达卡



京公网安备 11010802022788号







