Published on :
Macro CREATION_INTERNE

AHGzero Macro for Numeric Formatting

This code is also available in: Deutsch Español Français
The `AHGzero` macro is designed to take a numeric value (`n`) and a desired length (`length`). It uses the SAS© `%SYSFUNC(PUTN())` function to convert the number `n` into a character string. The `PUTN` function is used to apply a numeric format without explicitly specifying a SAS© format, allowing SAS© to choose a default format or use an implicit format to display the number at the requested length. This can be useful for adding leading zeros to a number if the specified length is greater than the number of digits in the number. The goal is often to ensure uniform presentation of numbers, for example, for identifiers requiring a fixed length.
Data Analysis

Type : CREATION_INTERNE


Data is passed directly as parameters to the macro and processed internally. No external data sources (files, databases) are used.

1 Code Block
MACRO
Explanation :
This block defines the `AHGzero` macro which encapsulates the `%SYSFUNC(putn(&n,&length))` function. `%SYSFUNC` allows calling SAS data functions (like `PUTN`) within the macro processor environment. `PUTN(&n,&length)` converts the numeric value of the macro variable `n` into a text format of the length specified by `length`. This function is useful for character string formatting.
Copied!
1%macro AHGzero(n,LENGTH);
2%sysfunc(putn(&n,&LENGTH))
3%mend;
4 
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.