Published on :
ETL CREATION_INTERNE

Definition of Nested Formats and Validation

This code is also available in: Deutsch Español Français
This script defines two formats using PROC FORMAT. The 'loads' format defines labels for value ranges. The 'couple' format demonstrates a nesting technique: it applies the 'loads' format for values between 5000 and 10000, handles a specific value (2), and applies a standard 'comma6.' format for other cases. A Data Step _null_ is used to test these formats on internal data.
Data Analysis

Type : CREATION_INTERNE


Data is defined directly in the script via the CARDS statement.

1 Code Block
PROC FORMAT
Explanation :
Definition of 'loads' and 'couple' formats. Note the use of square brackets [ ] in 'couple' to dynamically call another format ('loads') or a system format ('comma').
Copied!
1PROC FORMAT ;
2 value loads
3 5000-<6000 = 'Over 5,000'
4 6000-<7000 = 'Over 6,000'
5 7000-<8000 = 'Over 7,000'
6 8000-<9000 = 'Over 8,000'
7 other = 'Mega!' ;
8 
9 value couple
10 2 = 'Bingo!'
11 5000-<10000 = [loads10.]
12 other=[comma6.] ;
13RUN ;
2 Code Block
DATA STEP
Explanation :
Execution Data Step that does not create an output table (_null_). It reads in-line data (CARDS) and writes the formatted value of 'x' to the log via the PUT statement.
Copied!
1DATA _null_ ;
2 INPUT x ;
3 put x couple. ;
4 CARDS;
57777
61234
72
823
9;
10RUN ;
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.