Previous Page | Next Page

SAS Component Language Dictionary

PUTVARC and PUTVARN



Write a value to the Table Data Vector (TDV) for a SAS table
Category: SAS Table

Syntax
Details
Examples
Example 1: Using the PUTVARC Routine
Example 2: Using the PUTVARN Routine
See Also

Syntax

CALL PUTVARC(table-id,col-num,cval);
CALL PUTVARN(table-id,col-num,nval);

table-id

is the identifier that was assigned when the table was opened. If table-id is invalid, the program halts.

Type: Numeric

col-num

is the number of the column in the SAS table. This is the number that is adjacent to the column when the CONTENTS procedure lists the columns in the SAS table. You can use the VARNUM function to obtain this value.

Type: Numeric

cval

is the character value to be written to the TDV.

Type: Character

nval

is the numeric value to be written to the TDV.

Type: Numeric


Details

After PUTVARC writes a character value to a table column, use UPDATE to update the row in the SAS table.

If the SCL program uses CALL SET to link columns in the SCL data vector (SDV) with columns in the Table Data Vector (TDV), do not use the PUTVARN and PUTVARC routines for any columns that are linked by SET. UPDATE and APPEND automatically copy the data from the SDV to the TDV before writing a row to a physical file. Therefore, the value that is copied from the SDV will overwrite the value written to the TDV by PUTVARC or PUTVARN, and the value of the corresponding table column will not be updated with the value specified by PUTVARC or PUTVARN.


Examples


Example 1: Using the PUTVARC Routine

Change an employee's last name from SMITH to UPDIKE in the column NAME in the table referenced by the table identifier PAYID:

vnum=varnum(payid,'name');
rc=locatec(payid,vnum,'SMITH','u');
if (rc>0) then
   do;
      call putvarc(payid,vnum,'UPDIKE');
      rc=update(payid);
   end;


Example 2: Using the PUTVARN Routine

Change an item's price from 1.99 to 2.99 in the table referenced by the table identifier PAYID:

vnum=varnum(payid,'price');
rc=locaten(payid,vnum,1.99,'u');
if (rc>0) then
   do;
      call putvarn(payid,vnum,2.99);
      rc=update(payid);
   end;


See Also

APPEND

FETCH

FETCHOBS

GETVARC and GETVARN

INITROW

UPDATE

VARNUM

Previous Page | Next Page | Top of Page