Published on :
Macro INTERNAL_CREATION

Creation of Base Datasets

This code is also available in: Deutsch Español Français
Awaiting validation
The `basedatasets` macro is designed to generate dummy data for testing or demonstration purposes. It includes three distinct DATA steps: one for customers, one for contracts, and one for customer-contract association. Each DATA step uses a `DO` loop to create a defined number of observations with calculated values for key variables. This is typical for unit test base data, often found in frameworks like SASUnit.
Data Analysis

Type : INTERNAL_CREATION


Data is entirely generated within the SAS script via DATA steps, creating observations for the 'Customer', 'Contracts', and 'CustomerContracts' tables in the temporary work library.

1 Code Block
DATA STEP Data
Explanation :
Creates the `work.Customer` dataset with 5 observations. Each observation contains a `CustomerNumber` (from 1 to 5) and a formatted `CustomerName` (e.g., 'Customer 01'). The temporary variable `i` is dropped at the end of the DATA step.
Copied!
1DATA work.Customer;
2 DO i=1 to 5;
3 CustomerNumber=i;
4 CustomerName="Customer " || put (i,z2.);
5 OUTPUT;
6 END;
7 drop i;
8RUN;
2 Code Block
DATA STEP Data
Explanation :
Creates the `work.Contracts` dataset with 8 observations. Each observation receives a `ContractNumber` (from 1 to 8) and a `ContractType` calculated using the `MOD` function (modulo), resulting in types 1, 2, or 3. The temporary variable `i` is dropped.
Copied!
1DATA work.Contracts;
2 DO i=1 to 8;
3 ContractNumber=i;
4 ContractType=mod (i,3)+1;
5 OUTPUT;
6 END;
7 drop i;
8RUN;
3 Code Block
DATA STEP Data
Explanation :
Creates the `work.CustomerContracts` dataset with 8 observations. This dataset associates a `ContractNumber` (from 1 to 8) with a `CustomerNumber` calculated via the `MOD` function, simulating a relationship between customers and contracts. The temporary variable `i` is dropped.
Copied!
1DATA work.CustomerContracts;
2 DO i=1 to 8;
3 ContractNumber=i;
4 CustomerNumber=mod (i,5)+1;
5 OUTPUT;
6 END;
7 drop i;
8RUN;
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 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de. This file is part of SASUnit, the Unit testing framework for SAS(R) programs.