In SAS/AF, you can use the table viewer control to display the contents of a model such as the SAS Data Set model. One customization that you can make is to enable users to sort the contents displayed in the viewer by clicking on the column headers. The SCL code on the Full Code tab provides an example of how to implement sorting in the table viewer control.
For more information about SAS/AF, see the SAS/AF documentation page.
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 runObjectLabel attribute of TableViewer1 must be set to "Single Click" for this example to work correctly.
Copy the code below into the SCL for the frame and then compile it.
For the purposes of this example, a copy of the SASHELP.CLASS table was created in the Work library. To use a different table, change the following line in the code:
sasdataset1.table='work.class';
Single clicking on a column header will sort the displayed data in the table based on ascending order of the selected variable.
dcl char(8) colname;
init:
sasdataset1.table='work.class';
sasdataset1.editMode='rowLevelEdit';
rowlist=makelist();
collist=makelist();
return;
tableviewer1:
/* click on column label to sort the table by that column */
tableviewer1._getActiveCell(rowlist,collist);
if listlen(rowlist) gt 0 then
do;
rownum=getitemn(rowlist,1);
if rownum=0 then
do;
colnum=getitemn(collist,1);
sasdataset1._getDisplayedColumnName(colnum,colname);
sortlist=makelist();
/* if you wish to sort in descending order, uncomment */
/* the following statement */
* rc=insertc(sortlist,'descending',-1);
rc=insertc(sortlist,colname,-1);
rc=sasdataset1._sort(sortlist);
if sortlist then sortlist=dellist(sortlist);
end;
end;
return;
term:
if rowlist then rowlist=dellist(rowlist);
if collist then collist=dellist(collist);
return;
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.
This zip file contains a compiled version of the application described in this sample. The application is contained in a SAS transport file. Before you can use the application, you must use PROC CIMPORT to extract it:
PROC CIMPORT lib=work infile='<path to sample.xpt>';
RUN;
|
Type: | Sample |
Date Modified: | 2010-02-11 16:00:32 |
Date Created: | 2010-02-11 14:43:10 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/AF | OS/2 | 8.2 TS2M0 | |
Microsoft Windows 95/98 | 8.2 TS2M0 | |||
Microsoft Windows 2000 Advanced Server | 8.2 TS2M0 | |||
Microsoft Windows 2000 Datacenter Server | 8.2 TS2M0 | |||
Microsoft Windows 2000 Server | 8.2 TS2M0 | |||
Microsoft Windows 2000 Professional | 8.2 TS2M0 | |||
Microsoft Windows NT Workstation | 8.2 TS2M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 8.2 TS2M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 8.2 TS2M0 | |||
Microsoft Windows Server 2003 Standard Edition | 8.2 TS2M0 | |||
Microsoft Windows XP Professional | 8.2 TS2M0 | |||
Windows Millennium Edition (Me) | 8.2 TS2M0 | |||
64-bit Enabled AIX | 8.2 TS2M0 | |||
64-bit Enabled HP-UX | 8.2 TS2M0 | |||
64-bit Enabled Solaris | 8.2 TS2M0 | |||
ABI+ for Intel Architecture | 8.2 TS2M0 | |||
AIX | 8.2 TS2M0 | |||
HP-UX | 8.2 TS2M0 | |||
IRIX | 8.2 TS2M0 | |||
Linux | 8.2 TS2M0 | |||
OpenVMS Alpha | 8.2 TS2M0 | |||
Solaris | 8.2 TS2M0 | |||
Tru64 UNIX | 8.2 TS2M0 |