SAS Component Language Dictionary |
Appends a new row to a SAS table
sysrc=APPEND(table-id<,option>);
|
-
sysrc
-
contains the return code for the
operation:
0 |
successful |
0 |
an error or warning condition occurred |
-
table-id
-
contains the identifier for the SAS
table, which is returned by the OPEN function.
Type: Numeric
-
option
-
is one of the following options:
-
'NOSET'
-
appends a row with all column values
set to missing, even if the SET routine has been called.
-
'NOINIT'
-
appends a row with the values currently
in the Table Data Vector (TDV), even if the SET routine has not been called.
Type:
Character
APPEND adds a row to the end of a SAS
table. By default, the added row contains missing values. However, you can
add a row with the current values in the TDV if SET has been called or if
the NOINIT option is specified as the second argument. If SET has been called,
the NOSET argument can still force APPEND to fill the row with missing values.
If the SET routine has not been called, you can PUTVARC
and PUTVARN to specify values for each column in the TDV before calling APPEND
with the NOINIT option. You can use INITROW to initialize the TDV to missing
to prevent APPEND from writing bad data to a row values are not explicitly
assigned to some columns through PUTVARC or PUTVARN.
Add a row to the SAS table WORK.DATAONE,
which has two columns, FNAME and SSN. Because SET is called, the values ROBERT and 999-99-9999 are
written to the new row.
tableid=open('work.dataone','u');
call set(tableid);
fname='Fname';
ssn='999-99-9999';
if (append(tableid)) then do;
_msg_=sysmsg();
If SET had not been called, then using the NOINIT option
would produce the same results:
tableid=open('work.dataone','u');
fname='ROBERT';
ssn='999-99-9999';
call putvarc(tableid,varnum(tableid,'fname'),fname);
call putvarc(tableid,varnum(tableid,'ssn'),ssn);
if (append(tableid,'noinit')) then
_msg_=sysmsg();
OPEN
PUTVARC and PUTVARN
SET
UPDATE
INITROW
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.