GETVARN Function


GETVARN Function

Returns the value of a SAS data set numeric variable

Category: SAS File I/O

Syntax

GETVARN ( data-set-id , var-num )

Arguments

data-set-id

  • specifies the data set identifier that the OPEN function returns.

var-num

  • is the number of the variable in the Data Set Data Vector (DDV).

  • Tip: You can obtain this value by using the VARNUM function.

  • Tip: This value is listed next to the variable when you use the CONTENTS procedure.

Details

Use VARNUM to obtain the number of a variable in a SAS data set. You can nest VARNUM or you can assign it to a variable that can then be passed as the second argument, as shown in the "Examples" section. GETVARN reads the value of a numeric variable from the current observation in the Data Set Data Vector (DDV) into a macro variable or DATA step variable.

Examples

  • This example obtains the entire tenth observation from a SAS data set. The data set must have been previously opened using OPEN. The data set identifier value for the open data set is stored in the variable MYDATAID. This example nests VARNUM, and reads in the value of the numeric variable PRICE from the tenth observation of an open SAS data set.

     %let rc=%sysfunc(fetchobs(&mydataid,10));  %let price=%sysfunc(getvarn(&mydataid,                     %sysfunc(varnum                          (&mydataid,price)))); 
  • This example assigns VARNUM to a variable that can then be passed as the second argument. This example fetches data from observation 10.

     %let pricenum=%sysfunc(varnum                        (&mydataid,price));  %let rc=%sysfunc(fetchobs(&mydataid,10));  %let price=%sysfunc(getvarn                     (&mydataid,&pricenum)); 

See Also

Functions:

  • 'FETCH Function' on page 523

  • 'FETCHOBS Function' on page 524

  • 'GETVARC Function' on page 572

  • 'VARNUM Function' on page 877




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net