Sample 43589: New DELIMITER= and SUFFIX= options for constructing variable names with PROC TRANSPOSE in SAS® 9.2
This sample demonstrates the use of two new options for constructing variable names with PROC TRANSPOSE. The DELIMITER= and SUFFIX= options were added as new features in SAS® 9.2.
The DELIMITER= option specifies the delimiter to use if one or more variables have been specified in the ID statement in PROC TRANSPOSE. The delimiter is inserted between the variable name values that are contained in the output data set created by PROC TRANSPOSE.
The SUFFIX= option enables you to add a suffix to a variable name when constructing a variable that is contained in the output data set created by PROC TRANSPOSE.
The code on the Full Code tab provides an example.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The sample code below demonstrates the use of the new DELIMITER= and SUFFIX= options in PROC TRANSPOSE, which were added in SAS® 9.2.
/* Create sample data. */
data one;
input Region $ Year Group $ Scores;
datalines;
East 2008 grp1 323
East 2009 grp1 425
East 2010 grp1 112
East 2008 grp2 220
East 2009 grp2 392
East 2010 grp2 434
South 2008 grp1 232
South 2009 grp1 110
South 2010 grp1 120
South 2008 grp2 214
South 2009 grp2 100
South 2010 grp2 155
West 2008 grp3 535
West 2009 grp3 235
West 2010 grp3 424
;
run;
/* Sort the data by Year. */
proc sort data=one out=srtds;
by year;
run;
/* Transpose the data set. */
/* Assign a delimiter of "_", */
/* a suffix of _SCORES, and a prefix. */
proc transpose data=srtds out=final(drop=_name_) prefix=Region_ delimiter=_ suffix=_Scores;
var Scores;
id Region Group;
by Year;
run;
/* View the contents of the transposed data set. */
proc contents data=final;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The CONTENTS Procedure
Alphabetic List of Variables and Attributes
# Variable Type Len
2 Region_East_grp1_Scores Num 8
3 Region_East_grp2_Scores Num 8
4 Region_South_grp1_Scores Num 8
5 Region_South_grp2_Scores Num 8
6 Region_West_grp3_Scores Num 8
1 Year Num 8
This sample demonstrates the use of two new options for constructing variable names with PROC TRANSPOSE. The DELIMITER= and SUFFIX= options were added as new features in SAS® 9.2.
Date Modified: | 2021-05-07 10:29:38 |
Date Created: | 2011-06-24 11:11:57 |
Operating System and Release Information
SAS System | Base SAS | Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.21 | | 9.2 TS2M0 | |
z/OS | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows XP 64-bit Edition | 9.21 | | 9.2 TS2M0 | |
Microsoft® Windows® for x64 | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 for x64 | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows Server 2008 for x64 | 9.21 | | 9.2 TS2M0 | |
Microsoft Windows XP Professional | 9.21 | | 9.2 TS2M0 | |
Windows Vista | 9.21 | | 9.2 TS2M0 | |
Windows Vista for x64 | 9.21 | | 9.2 TS2M0 | |
64-bit Enabled AIX | 9.21 | | 9.2 TS2M0 | |
64-bit Enabled HP-UX | 9.21 | | 9.2 TS2M0 | |
64-bit Enabled Solaris | 9.21 | | 9.2 TS2M0 | |
HP-UX IPF | 9.21 | | 9.2 TS2M0 | |
Linux | 9.21 | | 9.2 TS2M0 | |
Linux for x64 | 9.21 | | 9.2 TS2M0 | |
OpenVMS on HP Integrity | 9.21 | | 9.2 TS2M0 | |
Solaris for x64 | 9.21 | | 9.2 TS2M0 | |