Usage Note 22932: How can I use PROC TRANSPOSE to get one record per BY group?
Because of the structure of a data set, using the BY statement
does not always guarantee that PROC TRANSPOSE will create an output data set with
one record per BY group. In some cases it is necessary to use a BY variable
that is unique for every record (if one does not already exist in the data
set, use _N_), and then transpose the data set a second time.
data test;
n=_n_;
input x y z;
cards;
1 2 3
1 2 3
2 3 4
3 4 5
3 4 5
4 4 5
;
/* In order to keep the implied ID variable _NAME_ */
/* from causing errors in the second transpose, */
/* eliminate it using the drop= data set option */
proc transpose out=first(drop=_name_);
by n x;
var y z;
proc print; run;
proc transpose data=first out=second prefix=a;
by x;
var col1;
proc print; run;
Operating System and Release Information
| Product Family | Product | System | Reported Release | Fixed Release* |
| SAS System | Base SAS | All | n/a | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
| Type: | Usage Note |
| Priority: | low |
| Topic: | SAS Reference ==> Procedures ==> TRANSPOSE
|
| Date Modified: | 2007-12-03 14:57:25 |
| Date Created: | 2002-12-16 10:56:36 |