Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_getvarformat.sas File Reference

Returns the format of a variable. More...

Go to the source code of this file.

Detailed Description

Uses varfmt function to identify the format of a particular variable. Usage:

data test;
  format str1 $1.  num1 datetime19.;
  str2='hello mum!'; num2=666;
  stop;
run;
%put %mf_getVarFormat(test,str1);
%put %mf_getVarFormat(work.test,num1);
%put %mf_getVarFormat(test,str2,force=1);
%put %mf_getVarFormat(work.test,num2,force=1);
%put %mf_getVarFormat(test,renegade);

returns:

$1.
DATETIME19.
$10.
8.
NOTE: Variable renegade does not exist in test
Parameters
[in]libdsTwo part dataset (or view) reference.
[in]varVariable name for which a format should be returned
[in]force=(0) Set to 1 to supply a default if the variable has no format
Returns
outputs format
Author
Allan Bowe
Version
9.2

Definition in file mf_getvarformat.sas.