Published on :
Data Preparation NON_APPLICABLE

Custom INVALUE Format Definition

This code is also available in: Deutsch Español Français
Awaiting validation
This SAS© code creates an INVALUE format named 'infNum'. This format is designed to convert character strings into their corresponding numerical representations. Specifically, 'negative' is mapped to -1, 'zero' to 0, 'positive' to 1, and 'missing' to the numerical missing value (.). Any other character string encountered by this format will be mapped to the value 42. This format is very useful for standardizing textual data for numerical analysis or for managing categorical codes during data ingestion.
Data Analysis

Type : NON_APPLICABLE


The script does not directly read SASHELP or external data; it defines a format that will be applied to data later. The format definition itself is internal to the script.

1 Code Block
PROC FORMAT (INVALUE) Data
Explanation :
This block defines the INVALUE 'infNum' format. It establishes conversion rules where specific character strings are transformed into predefined numerical values. The 'other = 42' clause ensures that a numerical value is always assigned, even for unlisted inputs.
Copied!
1invalue infNum
2"negative" = -1
3"zero" = 0
4"positive" = 1
5"missing" = .
6other = 42
7;
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.