Using SCL methods
and the OLE automation server, SAS lets you
-
receive a single-dimensional array
that is passed to SAS as an SCL list
-
send or receive multi-dimensional
SCL arrays.
In this first example,
the SCL code creates and populates a list box in a Microsoft Excel
worksheet and stores the contents of the list box in an SCL list:
list=makelist(); /* create the SCL list */
/* Add a Listbox in a worksheet */
call send(worksht, '_COMPUTE_', 'Listboxes',
listbox);
call send(listbox, '_DO_', 'Add', 20, 50,
40, 100);
call send(worksht, '_COMPUTE_', 'Listboxes',
1, listone);
/* Fill the Listbox with a range of */
/* values from the worksheet */
call send(listone, '_SET_PROPERTY_',
'ListFillRange', 'A1:A3');
/* Get the contents of the Listbox */
call send(listone, '_GET_PROPERTY_',
'List', list);
Using several SCL arrays,
the following SCL code creates and populates another Microsoft Excel
worksheet:
Init:
/* Initialization */
HostClass = loadclass('sashelp.fsp.hauto');
/* Instantiate the Excel object and make it visible */
call send (Hostclass, '_NEW_', ExcelObj, 0, 'Excel.Application');
call send (ExcelObj, '_SET_PROPERTY_', 'Visible', -1);
/* Get the Workbook Object, add a new Sheet and get the Sheet object */
call send (ExcelObj, '_GET_PROPERTY_', 'Workbooks', WkBkObj);
call send (WkBkObj, '_DO_', 'Add');
call send (ExcelObj, '_GET_PROPERTY_', 'ActiveSheet', WkShtObj);
dcl char names{3,2) = ('Lucy', 'Ricky',
'Julliette', 'Romeo',
'Elizabeth', 'Richard');
/* Set the range to be A1:A4 and fill that range with names */
call send(WkShtObj, '_COMPUTE_', 'Range', 'A1', 'B3', RangeObj);
call send(RangeObj, '_SET_PROPERTY_', 'Value', names);
dcl num primes{2,4} = ( 1, 3, 5, 7,
11, 13, 17, 23);
/* Set the range to be A5:D6 and fill that range with ints values */
call send(WkShtObj, '_COMPUTE_', 'Range', 'A5', 'D6', RangeObj);
call send(RangeObj, '_SET_PROPERTY_', 'Value', primes);
dcl char totals{1,4} = ('=SUM(A5,A6)',
'=SUM(B5,B6)',
'=SUM(C5,C6)',
'=SUM(D5,D6)');
/* Set the range to be A1:A4 and fill that range with totals */
call send(WkShtObj, '_COMPUTE_', 'Range', 'A7', 'D7', RangeObj);
call send(RangeObj, '_SET_PROPERTY_', 'Value', totals);
dcl char vals{7,4};
call send(WkShtObj, '_COMPUTE_', 'Range', 'A5', 'D7', RangeObj);
call send(RangeObj, '_GET_PROPERTY_', 'Value', vals);
return;