CORE
mf_getvarnum.sas
Go to the documentation of this file.
1 
32 %macro mf_getVarNum(libds /* two level ds name */
33  , var /* variable name from which to return the format */
34  );
35  %local dsid vnum rc;
36  /* Open dataset */
37  %let dsid = %sysfunc(open(&libds));
38  %if &dsid > 0 %then %do;
39  /* Get variable number */
40  %let vnum = %sysfunc(varnum(&dsid, &var));
41  %if(&vnum <= 0) %then %do;
42  %put NOTE: Variable &var does not exist in &libds;
43  %let vnum = %str( );
44  %end;
45  %end;
46  %else %put dataset &ds not opened! (rc=&dsid);
47 
48  /* Close dataset */
49  %let rc = %sysfunc(close(&dsid));
50 
51  /* Return variable number */
52  &vnum.
53 
54 %mend;