Montura Consulting   Research & Development
SAS/AF Tableviewer, SAS Dataset Model

 

Object Property

PUBLIC properties are similar %GLOBAL macro variables. NUM and CHAR are visible only within the currect program (object). A single LIST property can be shared between any number of objects, like a universal datavector.

class icon1 extends sashelp.classes.desktopicon_c.class;                  
public char backgroundColor / (state='o', initialValue='White');
public char iconStyle / (state='o', initialValue='Large Icons');
public num icon / (state='o', initialValue=212);
public char borderStyle / (state='o', initialValue='Shadow');
public char label / (state='o', initialValue='Data'); public list dataVector / (sendEvent='N');

_select: method / (state='o');
_super();
call goto('montura.????.frame.frame');
endmethod;
endclass;

TableViewer

There are three locations that return a ZERO for Row or Column

  • On the row lablel
  • On the column label
  • Below the data grid, but still within the viewer

Compensate for Null Values when other widgets are dependent on selected row.

  • Track the last row clicked
  • Preselect row #1 during Frame startup
class tableviewer1 extends sashelp.classes.tableviewer_c.class;      
public char rowLabels / (state='o', initialValue='No');

public list row / (sendEvent='N');
public list column / (sendEvent='N');
public list lastSelect / (sendEvent='N');

_select: method / (state='o');
_super();
dcl num newSelect=1;

_getActiveCell(row, column);

if listlen(row)=0 or listlen(column)=0 then newSelect=0;
if newSelect then
if getitemn(row)=0 or getitemn(column)=0 then newSelect=0;

if not newSelect then do;
_clearSelect();
_selectRow(lastSelect);
end;

if newSelect then do;
setnitemn(lastSelect, getitemn(row), '1');
_selectRow(row);
end;

_clearActiveCell();
_refresh();
endmethod;

_popup: method arg1 arg2:num / (state='o');
endmethod;

runPreselect: method;
setnitemn(lastSelect, 1, '1');
_selectRow(lastSelect);
_refresh();
endmethod;

endclass;

SAS Dataset Model

  • Use PUBLIC properties to eliminate method parameters.
  • Use PUBLIC LIST typecast properties whenever possible.
  • Use PUBLIC CHAR and PUBLIC NUM typecast properties when data will be resolved in submit blocks.
  • Multiple SAS dataset models may be used in the same frame.
  • Multiple SAS dataset models may be used by the same tableviewer.
class sd_cnameview extends sashelp.classes.sasdataset_c.class;                                 
public list dataVector / (sendEvent='N');
public char mpar / (sendEvent='N');

_init: method / (state='o');
_super();
_addEventHandler(frameID, 'frame startup', 'runStartup');
endmethod;

_getColumnDimInfo: method coladdr:list
elements subdim height:num
units:char
grouplst:list
eod:char / (state='o');

_super(coladdr, elements, subdim, height, units, grouplst, eod);

if (listlen(coladdr)=0) then do;
units='pt';
height=32;
end;
endmethod;

runSelected: method arg:list;
dcl num i;
dcl char rowValue;
dcl list gVector=getniteml(getniteml(envlist('G'), 'mpar'), 'population filter');

clearlist(gVector, 'D');

do i=1 to listlen(arg);
rowValue=getitemc(dataVector, getitemn(arg, i));
insertc(gVector, rowValue, -1, 'CNAME'||left(put(i, best.)));
end;

_frame_._sendEvent('selector changed');
endmethod;

runStartup: method;
call send(_self_, 'startup1');
call send(_self_, 'startup2');
call send(_self_, 'startup3');
call send(_self_, 'startup4');
endmethod;

startup1: method;
table='';
mpar='miwork.sd_cnameview';
endmethod;

startup2: method;
dcl list gVector=getniteml(getniteml(envlist('G'), 'mpar'), 'selector');
dcl char population=getnitemc(gVector, 'analysis table');

dcl char tokenLibname=upcase(scan(population, 1, '.'));
dcl char tokenTable =upcase(scan(population, 2, '.'));

submit continue sql;
create table &mpar as
select name, label, type, length, format
from sashelp.vcolumn
where libname='&tokenLibname' and
memname='&tokenTable';
quit;
endsubmit;
endmethod;

startup3: method;
dcl num dset;
dset=open(mpar, 'i');
do while (fetch(dset)=0);
insertc(dataVector, getvarc(dset, varnum(dset, 'name')), -1);
end;
close(dset);
endmethod;

startup4: method;
table=mpar;

wrapLabelText='No';
wrapDataText='Yes';

_setColumnWidth('name', 60);
_setColumnWidth('label', 164);
endmethod;

_term: method / (state='o');
table='';
delete(mpar);

_super();
endmethod;
endclass;

Class Property vs. Method Property

  • Length as a class property: 32768
  • Length as a method property: 200
class ???? extends sashelp.classes.????.class;                                 
public char mpar / (sendEvent='N');
    startup1: method;                                                                          
dcl char mpar;

Events

Events may affect every object and widget in the session. Programmers can coordinate complex interactions between SAS/AF GUI widgets and other objects that are not liked to any Frame.

  • Events may be used in batch-mode and GUI applications.

Step #1: Define the event

class radiobox1 extends sashelp.classes.radiobox_c.class; 
_select: method / (state='o');
_super();

frameID._sendEvent(nameitem(items,selectedIndex));
_refresh();
endmethod;

_init: method / (state='o'); _super();
clearlist(items);

insertc(items, 'Refresh TOC', -1, 'IMPORT TOC');
insertc(items, 'Import Worksheet/Domain', -1, 'IMPORT DOMAINS');
selectedItem=getitemc(items, 1);
_refresh();
endmethod;
endclass;

Step #2: Define a method that is executed in response

class listbox1 extends sashelp.classes.listbox_c.class; 
    eventhandler runBehavior1 / (sender='*', event='IMPORT TOC')

_init: method / (state='o');
_super();

_addEventHandler(frameID, 'IMPORT TOC', 'runTOC'); _addEventHandler(frameID, 'RESET', 'runTOC');
_addEventHandler(frameID, 'IMPORT DOMAINS', 'runDomains');
endmethod; runBehavior1: method; * more sas statements ; endmethod;
endclass;

 

Widgets have bulit-in functionality that detects mouse clicks. Widgets are created specifically for use with SAS/Frame and must be linked to a Frame to function correctly.

  • pushbutton
  • check box table viewer
  • etc.

Objects run like a batch mode SAS program, and may optionally be attached to a frame.


 

COPYRIGHT © 1989 - 2010 Montura, Inc.
All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

Terms & Conditions -- Privacy Policy