Chapter Contents

Previous

Next
GETVARC and GETVARN

GETVARC and GETVARN



Assign the value of a SAS table column to an SCL variable

Category: SAS Table


Syntax
Details
Examples
Example 1: Using GETVARN to Search for a Value
Example 2: Using GETVARC with a Nested VARNUM
See Also

Syntax

cval=GETVARC(table-id,col-num);
nval=GETVARN(table-id,col-num);

cval
is the value of the character column that is returned by GETVARC.

Type: Character

table-id
is the identifier for a table that is open. If table-id is invalid, the program halts.

Type: Numeric

col-num
is the number of the column in the Table Data Vector (TDV). This value can be obtained by using the VARNUM function. If the column specified in col-num is invalid, the program halts.

Type: Numeric

nval
is the value of the numeric column that is returned by GETVARN.

Type: Numeric


Details

Before you use GETVARC or GETVARN, you can use VARNUM to obtain the number of a column in a SAS table. You can nest VARNUM, or you can assign it to a column that can be passed as the second argument. GETVARC and GETVARN read the value of the specified column that is in the current row in the TDV and copy that value to the specified SCL variable in the SCL data vector (SDV).


Examples

Example 1: Using GETVARN to Search for a Value

Assign VARNUM to a column that can be passed as the second argument to GETVARN. Read row number 10 into the TDV.

pricenum=varnum(mydataid,'price');
rc=fetchobs(mydataid,10);
price=getvarn(mydataid,pricenum);

Example 2: Using GETVARC with a Nested VARNUM

Nest VARNUM in the GETVARC function to search for the value of the character column NAME from the tenth row of the open SAS table whose identifier is stored in the column MYDATAID.

rc=fetchobs(mydataid,10);
user=getvarc(mydataid,varnum(mydataid,'name'));

See Also

FETCH

FETCHOBS

LOCATEC and LOCATEN

PUTVARC and PUTVARN

UPDATE

VARNUM


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.