CORE
mf_getvartype.sas
Go to the documentation of this file.
1 
26 %macro mf_getvartype(libds /* two level name */
27  , var /* variable name from which to return the type */
28  );
29  %local dsid vnum vtype rc;
30  /* Open dataset */
31  %let dsid = %sysfunc(open(&libds));
32  %if &dsid. > 0 %then %do;
33  /* Get variable number */
34  %let vnum = %sysfunc(varnum(&dsid, &var));
35  %if(&vnum. > 0) %then
36  /* Get variable type (C/N) */
37  %let vtype = %sysfunc(vartype(&dsid, &vnum.));
38  %else %do;
39  %put NOTE: Variable &var does not exist in &libds;
40  %let vtype = %str( );
41  %end;
42  %end;
43  %else %put dataset &libds not opened! (rc=&dsid);
44 
45  /* Close dataset */
46  %let rc = %sysfunc(close(&dsid));
47  /* Return variable type */
48  &vtype
49 %mend;