Published on :
ETL CREATION_INTERNE

Currency management and display

This code is also available in: Deutsch Español Français
Awaiting validation
The script is divided into two sections. The first section creates a dataset named `mycur` with a `price` variable configured to read and display values in US dollars (format `dollar8.`), then displays it. The second section redefines the `mycur` dataset, this time with the `price` variable configured for euros (format `nlmnleur15.2`), and also displays the result. This demonstrates how SAS© handles the interpretation and display of monetary data according to the formats specified in a SAS© Viya 4 and SAS© Studio environment.
Data Analysis

Type : CREATION_INTERNE


Data is created directly within the script using the `cards;` statement in DATA steps.

1 Code Block
DATA STEP Data
Explanation :
This DATA block creates the `mycur` dataset. The `price` variable is defined with the `dollar8.` informat and format to read and display monetary values in US dollars. The value `$1000000` is provided directly in the script via the `cards;` statement.
Copied!
1DATA mycur;
2informat price dollar8.;
3FORMAT price dollar8.;
4INPUT price;
5CARDS;
6$1000000
7;
8RUN;
2 Code Block
PROC PRINT
Explanation :
This PROC PRINT displays the contents of the `mycur` dataset as it was created and formatted in dollars in the previous block.
Copied!
1PROC PRINT DATA=mycur;
2RUN;
3 Code Block
DATA STEP Data
Explanation :
This DATA block recreates the `mycur` dataset, replacing the previous version. It uses the `nlmnleur15.2` informat and format, which is suitable for reading and displaying monetary values in euros. The new value `€1000000` is inserted via `cards;`.
Copied!
1DATA mycur;
2informat price nlmnleur15.2;
3FORMAT price nlmnleur15.2;
4INPUT price;
5CARDS;
61000000
7;
8RUN;
4 Code Block
PROC PRINT
Explanation :
This PROC PRINT displays the updated content of the `mycur` dataset, showing the new `price` value formatted in euros.
Copied!
1PROC PRINT DATA=mycur;
2RUN;
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.