Published on :
Macro CREATION_INTERNE

Format application macro and left alignment

This code is also available in: Deutsch Español Français
This macro takes a variable and a format as input. If the format is not specified (checked by the external macro %AHGblank), it uses the 'best.' format. It then applies the format via the `put` function and left-aligns the result with `left`. It is designed to be used in DATA steps or SQL procedures.
Data Analysis

Type : CREATION_INTERNE


String processing macro, does not depend on external data tables.

1 Code Block
MACRO
Explanation :
Definition of the %ahgputn macro. It first checks if the format parameter is empty via the %AHGblank call. If so, it forces the 'best.' format. Then, it generates SAS code combining the `left` and `put` functions to format the value and remove leading spaces.
Copied!
1%macro ahgputn(var,fmt);
2%IF %AHGblank(&fmt) %THEN %let fmt=best.;
3left(put(&var,&fmt))
4%mend;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.