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