Published on :
Macro MIXTE

Utility macro to determine the extension of SAS catalogs

This code is also available in: Français Deutsch Español
This macro analyzes a SAS© version number passed as a parameter to return the corresponding SAS© catalog file extension. It handles different version formats (e.g., 'V8', '8.2', '802') by normalizing them. It is a compatibility tool for working with catalogs from different SAS© versions. If no version is specified, it attempts to determine the extension for the currently running SAS© version. The source code is published under the 'GNU General Public License'.
Data Analysis

Type : MIXTE


The macro does not use any datasets. It relies on information that can be either external (a text parameter provided by the user during the call) or internal (the version of the current SAS system).

1 Code Block
MACRO
Explanation :
This block defines the '%_catext' macro. It takes an argument 'arg1' (with an alias 'version') which represents the SAS version. The code normalizes this character string: it converts it to uppercase, removes the 'V' prefix and periods, then pads it with zeros. A series of '%if/%then/%else' conditions selects the appropriate catalog extension ('sas7bcat', 'sc2', etc.) based on the normalized version number. If no argument is provided, it relies on the version of the active SAS session. The execution of this macro depends on the availability of other non-standard macros (%_substr, %_repeat, %_version, %_unwind) that are not defined in this code.
Copied!
1%macro _catext(arg1, version=&arg1);
2 
3%IF %LENGTH(&version) %THEN %DO;
4 %local i;
5 %let version=%upcase(&version);
6 
7 %IF %_substr(&version, 1, 1)=V %THEN %let version=%_substr(&version, 2);
8 
9 %let i=%index(&version, .);
10 
11 %IF &i %THEN %let version=%_substr(&version, 1, &i-1)%_substr(&version, &i+1);
12 
13 %let version=&version%_repeat(0, 3-%LENGTH(&version));
14
15 %IF &version>=700 %THEN sas7bcat;
16 %ELSE %IF &version=607 | &version=609 %THEN sct??;
17 %ELSE %IF &version=608 | &version=610 %THEN sc2;
18 %ELSE %IF &version=603 %THEN sct;
19 %ELSE %_unwind(sct??, sc2, sct??);
20%END;
21%ELSE %DO;
22 %IF %_version(7) %THEN sas7bcat;
23 %ELSE %_unwind(sct??, sc2, sct??);
24%END;
25 
26%mend _catext;
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.
Copyright Info : Copyright (c) 2001-2004 Rodney Sparapani. The code is distributed under the terms of the 'GNU General Public License'.