The following example
uses the Business Card Request database that is supplied by Lotus
Notes. This DATA step creates a new document in the database and
supplies values for all of its fields.
Using the Business Card Request Database
01 filename reqcard NOTESDB;
02 data _null_;
03 file reqcard;
04 put '!NSF_DB! examples\buscard.nsf';
05 put '!NSF_FIELD!Status! Order';
06 put '!NSF_FIELD!Quantity! 500';
07 put '!NSF_FIELD!RequestedBy! Systems';
08 put '!NSF_FIELD!RequestedBy_CN! Jane Doe';
09 put '!NSF_FIELD!NameLine_1! Jane Doe';
10 put '!NSF_FIELD!NameLine_2! Developer';
11 put '!NSF_FIELD!AddressLine_1! Software R Us';
12 put '!NSF_FIELD!AddressLine_2! 123 Silicon Lane';
13 put '!NSF_FIELD!AddressLine_3! Garner, NC 27123';
14 put '!NSF_FIELD!AddressLine_4! USA';
15 put '!NSF_FIELD!PhoneLine_1! (910) 777-3232';
16 run;
Line 1 assigns a fileref
by using the FILENAME statement to point to Notes instead of to an
ordinary file. NOTESDB is the device type for Lotus Notes. Line 3
uses the assigned fileref to direct output from the PUT statement.
Line 4 indicates which Notes database to open. Lines 5 to 15 specify
the field and the value for that field for the new Notes document
that is being created. Status is the field name and Order is the
value that is placed in the Status field for the particular document.
Line 16 executes these SAS statements. A new Notes document is created
in the Business Card Request database.
The next example uses
each observation in the SALES data set to create a new document in
the
qrtsales.nsf
database and fills in the
Sales
,
Change
, and
Comments
fields for the documents.
Creating a New Document from a Data Set
01 data sasuser.sales;
02 length comment $20;
03 format comment $char20.;
04 input sales change comment $ 12-31;
05 datalines;
06 123472 342 Strong Increase
07 423257 33 Just enough
09 218649 4 Not high enough
09 ;
10 run;
11 filename sales NOTESDB;
12 data _null_;
13 file sales;
14 set sasuser.sales;
15 put '!NSF_DB! qrtsales.nsf';
16 put '!NSF_FORM! Jansales';
17 put '!NSF_ADD!';
18 put '!NSF_FIELD!Sales !' sales;
19 put '!NSF_FIELD!Change!' change;
20 put '!NSF_FIELD!Comments!' comment;
21 put '!NSF_CLR_FIELDS!';
22 run;
Line 11 assigns a fileref
by using the FILENAME statement to point to Notes instead of to an
ordinary file. NOTESDB is the device type for Lotus Notes. Line 13
uses the assigned fileref to direct the output from the PUT statement.
In line 15, the NSF_DB data directive indicates which Notes database
to open. Lines 18, 19, and 20 specify the field and its value for
the new Notes document that is being created.
Sales
is the field name and
sales
is the value
that is placed in the Status field for the particular document. Line
22 executes these SAS statements. A new Notes document is created
in the Sales database.
Expanding on the Business
Card Request database example, you can create multiple Notes documents
within a single DATA step or within SCL code by using action directives
as well as data directives. The following example shows how to create
multiple Notes documents within a single DATA step.
Creating Multiple Notes Documents within a Single DATA Step
01 filename reqcard NOTESDB;
02 data _null_;
03 file reqcard;
04 put '!NSF_DB!Examples\buscard.nsf';
05 put '!NSF_FIELD!Status! Order';
06 put '!NSF_FIELD!Quantity! 500';
07 put '!NSF_FIELD!RequestedBy!Systems';
08 put '!NSF_FIELD!RequestedBy_CN! Jane Doe';
09 put '!NSF_FIELD!NameLine_1! Jane Doe';
10 put '!NSF_FIELD!NameLine_2! Developer';
11 put '!NSF_FIELD!AddressLine_1! Software R Us';
12 put '!NSF_FIELD!AddressLine_2! 123 Silicon Lane';
13 put '!NSF_FIELD!AddressLine_3! Garner, NC 27123';
14 put '!NSF_FIELD!AddressLine_4! USA';
15 put '!NSF_FIELD!PhoneLine_1! (910) 555-3232';
16 put '!NSF_ADD!';
17 put '!NSF_CLR_FIELDS!';
18 put '!NSF_FIELD!Status! Order';
19 put '!NSF_FIELD!Quantity! 10';
20 put '!NSF_FIELD!RequestedBy! Research and Development';
21 put '!NSF_FIELD!RequestedBy_CN! John Doe';
22 put '!NSF_FIELD!NameLine_1! John Doe';
23 put '!NSF_FIELD!NameLine_2! Analyst';
24 put '!NSF_FIELD!AddressLine_1! Games Inc';
25 put '!NSF_FIELD!AddressLine_2! 123 Software Drive';
26 put '!NSF_FIELD!AddressLine_3! Cary, NC 27511';
27 put '!NSF_FIELD!AddressLine_4! USA';
28 put '!NSF_FIELD!PhoneLine_1! (910) 555-3000';
29 run;
Line 1 assigns a fileref
by using the FILENAME statement to point to Notes instead of to an
ordinary file. NOTESDB is the device type for Lotus Notes. Line 3
uses the assigned fileref to direct the output from the PUT statement.
Line 4 indicates which Notes database to open. Lines 5 to 15 specify
the field and the value for that field for the new Notes document
that is being created.
Status
is the field
name and
Order
is the value placed in the
Status
field for this particular document. Line 16 forces
the creation of a new Notes document. Line 17 clears the values for
the fields that are used with the !NSF_FIELD! data directives in the
previous lines. Lines 18 to 28 specify the field and the value for
that field for the second Notes document that is being created.
Status
is the field name and
Order
is the value placed in the
Status
field
for the second document. Line 29 executes these SAS statements. A
second Notes document is created in the Business Card Request database.
Only one !NSF_DB! data
directive is issued in the preceding example. By default, the second
Notes document is created in the same database as the one referenced
in the !NSF_DB! data directive on line 4. In order to create the
second Notes document in another database, you would have to issue
another !NSF_DB! data directive with the new database filename before
executing line 18. The key additions to this example are the action
directives on lines 16 and 17.
Note: All directives are not case
sensitive. However, the values following the data directives, such
as form name and field name, are case sensitive.