Using the DDE HOTLINK
If the HOTLINK option is specified, the DDE link is activated every time the data in the specified spreadsheet range are updated. In addition, DDE enables you to poll the data when the HOTLINK option is specified to determine whether data within the range specified have been changed. If no data have changed, the HOTLINK option returns a record of 0 bytes. In the following example, row 1, column 1 of the spreadsheet SHEET1 contains the daily production total. Every time the value in this cell changes, SAS reads in the new value and outputs the observation to a data set. In this example, a second cell in row 5, column 1 is defined as a status field. Once the user completes data entry, typing any character in this field terminates the DDE link:
/* Enter data into Excel SHEET1 in */
/* row 1 column 1. When you */
/* are through entering data, place */
/* any character in row 5 */
/* column 1, and the DDE link is */
/* terminated. */
filename daily
dde 'excel|sheet1!r1c1' hotlink;
filename status
dde 'excel|sheet1!r5c1' hotlink;
data daily;
infile status length=flag;
input @;
if flag ne 0 then stop;
infile daily length=b;
input @;
/* If data have changed, then the */
/* incoming record length */
/* is not equal to 0. */
if b ne 0 then
do;
input total $;
put total=;
output;
end;
run;
It is possible to establish multiple DDE sessions. The previous example uses two separate DDE links. When the HOTLINK option is used and there are multiple cells referenced in the item specification, if any one of the cells changes, then all cells are transmitted.
Unless the HOTLINK option is specified, DDE is performed as a single one-time data transfer. The values currently stored in the spreadsheet cells at the time that the DDE is processed are values that are transferred.
Partager