Published on :
Général CREATION_INTERNE

Sans titre

This code is also available in: Deutsch Español Français
The `AHGverCalc` macro is designed to incrementally or decrementally modify a part of a version string. It takes two parameters: `version` (a character string typically in 'X.Y' format) and `offset` (an integer). The macro extracts the first and second parts of the `version` string, applies the `offset` to the second (minor) part, and ensures that the result is not less than 1. It then returns the new formatted version string. This macro is useful for dynamic version management scenarios.
Data Analysis

Type : CREATION_INTERNE


The macro does not consume data from external sources or SAS libraries. It operates only on the parameters passed to it (`version` and `offset`), which are internal to the macro's execution.

1 Code Block
MACRO DEFINITION
Explanation :
This block defines the SAS macro `AHGverCalc`. It starts with a conditional check to ensure that if `offset` is 0, it is treated as -0 for operational consistency. Local variables `left` and `right` are declared. The macro uses `%scan` to extract the first and second parts of the `version` string. `%eval` is used to apply the `offset` to the `right` part. A check is performed to ensure the `right` value does not fall below 1. Finally, it returns a new string combining `left`, a period, and the new `right` value.
Copied!
1%macro AHGverCalc(version,offset);
2 %IF &offset=0 %THEN %let offset=-0;
3 %local left right;
4 %let left=%scan(&version,1);
5 %let right=%eval(%scan(&version,2)&offset);
6 %IF &right <=0 %THEN %let right=1;
7 &left..&right
8 %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.