Sample 31513: Outputting the largest value in a BY-Group in SAS® Enterprise Guide
SAS® Enterprise Guide can be used to output the largest value in a BY group. The following steps demonstrate how to perform this task.
- Bring the SASHELP.CLASS dataset into the project to use as sample data.
- Select the data set in the project, then open the Sort task from Data–>Sort Data
- Move the SEX, AGE, and HEIGHT variables over from Columns To Assign to Task
Roles and put them under the Sort by role
- Select HEIGHT, and change the Height sort order from Ascending to Descending. This will ensure that the largest height is in the first observation for each SEX and AGE group.
- Run the Sort task. Now the data is sorted by Sex, Age, and Height.
- Select the sorted data set and bring up the Sort Data task again. We are now going
to create the final data set, which has the largest height for each age by sex.
- This time, sort by SEX and AGE. Under Options, go to Duplicate Records and
select Keep only the first record for each 'Sort by' group. Run the Sort task to output the
first record for our sex and age groupings, which contains the largest height
because of our previous sort.
The final data set looks like this:
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.
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.
Use the SASHELP.CLASS dataset as sample data to show how to create an output data set that has the tallest person for each age group for both males and females.
Date Modified: | 2011-11-02 10:38:39 |
Date Created: | 2008-03-18 13:33:46 |
Operating System and Release Information
SAS System | SAS Enterprise Guide | Microsoft® Windows® for x64 | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 4.1 | | 9.1 TS1M3 SP4 | |
Windows Vista | 4.1 | | 9.1 TS1M3 SP4 | |