You can read data directly from the communications (serial)
port on your machine. To set the serial communications parameters,
use the port configuration tools in the Windows Control Panel to set
up the communications port. The communications parameters that you
specify are specific to each data collection device.
After you invoke SAS,
submit a FILENAME statement to associate a fileref with the communications
port, as in the following example:
filename test commport "com1:";
This FILENAME statement
defines the fileref TEST, uses the COMMPORT device-type keyword that
specifies you are going to use a communications port, and specifies
the COM1: reserved physical name.
Next, read the data
from COM1: into a SAS data set using the TEST fileref. The following
DATA step reads in the data, 1 byte at a time, until SAS encounters
an end-of-file (the hexadecimal value of end-of-file is
'1a'x
):
data acquire;
infile test lrecl=1 recfm=f unbuffered;
input i $;
/* Read until you find an end-of-file. */
if i='1a'x then stop;
run;
The communications port
can be accessed multiple times. However, while multiple reads are
allowed, only one user at a time can write to the port.
Two useful functions
in data acquisition applications are SLEEP and WAKEUP. These functions
enable you to control when your program is invoked. For example,
you can use the WAKEUP function to start your program at exactly 2:00
a.m. For more information about these two functions, see
SLEEP Function: Windows and
WAKEUP Function: Windows.