This article will cover the syntax of the ‘autonumber’ regular script statement.
The autonumber statement is used to create a unique integer value for each unique field value encountered in a script execution.
Statement syntax
AutoNumber fieldlist
Fieldlist | This is a comma separated list of fields where the values should be replaced by a unique integer. The ‘fieldlist’ supports use of wildcards. |
Example
This example loads 2 datasets. One contains a list of stores and total sales by month and year. The other contains a list of stores and the total number of customers by month and year. A key based on the year, month and store ID is created and converted from a long string into an integer value using the autonumber statement.
STORE_SALES:
LOAD
"Month"&'-'&"Year"&'-'&"Store ID" as Key,
"Total Sales"
INLINE [
Month, Year, Store ID, Total Sales
January, 2022, AYG-76, 500000
January, 2022, AZG-76, 50000
January, 2022, AZG-34, 350000
February, 2022, AYG-76, 450000
February, 2022, AZG-76, 60000
February, 2022, AZG-34, 375000
];
STORE_CUSTOMERS:
LOAD
"Month"&'-'&"Year"&'-'&"Store ID" as Key,
"Total Customers"
INLINE [
Month, Year, Store ID, Total Customers
January, 2022, AYG-76, 89000
January, 2022, AZG-76, 13000
January, 2022, AZG-34, 97000
February, 2022, AYG-76, 134000
February, 2022, AZG-76, 12000
February, 2022, AZG-34, 99500
];
Autonumber Key;
Result
Tables are created with a key field containing a unique integer representing identical field values in the key field.