VARNUM Function


VARNUM Function

Returns the number of a variable's position in a SAS data set

Category: SAS File I/O

Syntax

VARNUM ( data-set-id , var- name )

Arguments

data-set-id

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

var-name

  • specifies the variable's name.

Details

VARNUM returns the number of a variable's position in a SAS data set, or 0 if the variable is not in the SAS data set. This is the same variable number that is next to the variable in the output from PROC CONTENTS.

Examples

  • This example obtains the number of a variable's position in the SAS data set CITY, given the name of the variable.

     %let dsid=%sysfunc(open(city,i));  %let citynum=%sysfunc(varnum(&dsid,CITYNAME));  %let rc=%sysfunc(fetch(&dsid));  %let cityname=%sysfunc(getvarc                        (&dsid,&citynum)); 
  • This example creates a data set that contains the name, type, format, informat, label, length, and position of the variables in SASUSER. HOUSES .

     data vars;     length name $ 8 type $ 1            format informat $ 10 label $ 40;     drop dsid i num rc;     dsid=open("sasuser.houses","i");     num=attrn(dsid,"nvars");     do i=1 to num;        name=varname(dsid,i);        type=vartype(dsid,i);        format=varfmt(dsid,i);        informat=varinfmt(dsid,i);        label=varlabel(dsid,i);        length=varlen(dsid,i);        position=varnum(dsid,name);        output;     end;     rc=close(dsid);  run; 

See Also

Functions:

  • 'OPEN Function' on page 690

  • 'VARNAME Function' on page 876




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