tsReconcile

globalReconcile

Description

The `globalReconcile` action, part of the `Reconcile Forecasts Action Set`, simultaneously reconciles multiple levels within a hierarchy of forecasts. This utility function streamlines the process of adjusting forecasts across various aggregation levels to ensure consistency and coherence. It automatically infers the correct order of hierarchy levels based on the `groupBy` variables provided, allowing for flexible input specification.

tsReconcile.globalReconcile <result=results> <status=rc> / groupBy={"variable-name-1" <, "variable-name-2", ...>}, levels={{casOut={caslib="string", compress=TRUE | FALSE, indexVars={"variable-name-1" <, "variable-name-2", ...>}, label="string", lifetime=64-bit-integer, maxMemSize=64-bit-integer, memoryFormat="DVR" | "INHERIT" | "STANDARD", name="table-name", promote=TRUE | FALSE, replace=TRUE | FALSE, replication=integer, tableRedistUpPolicy="DEFER" | "NOREDIST" | "REBALANCE", threadBlockSize=64-bit-integer, timeStamp="string", where={"string-1" <, "string-2", ...>}}, roles={actual="variable-name", error="variable-name", name="variable-name", predict="variable-name"}, table={caslib="string", computedOnDemand=TRUE | FALSE, computedVars={{format="string", formattedLength=integer, label="string", name="variable-name", nfd=integer, nfl=integer}, {...}}, computedVarsProgram="string", dataSourceOptions={key-1=any-list-or-data-type-1 <, key-2=any-list-or-data-type-2, ...>}, groupByMode="NOSORT" | "REDISTRIBUTE", importOptions={fileType="ANY" | "AUDIO" | "AUTO" | "BASESAS" | "CSV" | "DELIMITED" | "DOCUMENT" | "DTA" | "ESP" | "EXCEL" | "FMT" | "HDAT" | "IMAGE" | "JMP" | "LASR" | "PARQUET" | "SOUND" | "SPSS" | "VIDEO" | "XLS", fileType-specific-parameters}, name="table-name", singlePass=TRUE | FALSE, vars={{format="string", formattedLength=integer, label="string", name="variable-name", nfd=integer, nfl=integer}, {...}}, where="where-expression", whereTable={casLib="string", dataSourceOptions={adls_noreq-parameters | bigquery-parameters | cas_noreq-parameters | clouddex-parameters | db2-parameters | dnfs-parameters | esp-parameters | fedsvr-parameters | gcs_noreq-parameters | hadoop-parameters | hana-parameters | impala-parameters | informix-parameters | jdbc-parameters | mongodb-parameters | mysql-parameters | odbc-parameters | oracle-parameters | path-parameters | postgres-parameters | redshift-parameters | s3-parameters | sapiq-parameters | sforce-parameters | singlestore_standard-parameters | snowflake-parameters | spark-parameters | spde-parameters | sqlserver-parameters | ss_noreq-parameters | teradata-parameters | vertica-parameters | yellowbrick-parameters}, importOptions={fileType="ANY" | "AUDIO" | "AUTO" | "BASESAS" | "CSV" | "DOCUMENT" | "DTA" | "ESP" | "EXCEL" | "FMT" | "HDAT" | "IMAGE" | "JMP" | "LASR" | "PARQUET" | "SPSS" | "VIDEO" | "XLS", fileType-specific-parameters}, name="table-name", vars={{format="string", formattedLength=integer, label="string", name="variable-name", nfd=integer, nfl=integer}, {...}}, where="where-expression"}}} <, {...}}>}, <nThreads=integer>, timeId="variable-name" ;
Settings
ParameterDescription
groupBySpecifies the groupBy variables. Alias: by.
levelsSpecifies each level of the hierarchy of forecasts. You can specify levels in any order, and the action infers the correct order on the basis of the groupBy variables.
levels.casOutSpecifies the output table of reconciled forecasts for this level of the hierarchy. This parameter is required for the bottom level of the hierarchy, but optional for other levels.
levels.casOut.caslibSpecifies the caslib for the output table. Defaults to the active caslib.
levels.casOut.compressSpecifies whether to compress the output table. Values: TRUE | FALSE.
levels.casOut.indexVarsSpecifies a list of variables to use for indexing the output table.
levels.casOut.labelSpecifies a descriptive label for the output table.
levels.casOut.lifetimeSpecifies the lifetime of the in-memory output table in minutes (64-bit integer).
levels.casOut.maxMemSizeSpecifies the maximum memory size for the output table in bytes (64-bit integer).
levels.casOut.memoryFormatSpecifies the memory format for the output table. Values: "DVR" | "INHERIT" | "STANDARD".
levels.casOut.nameSpecifies the name of the output table. Required.
levels.casOut.promoteSpecifies whether to promote the output table to a global scope. Values: TRUE | FALSE.
levels.casOut.replaceSpecifies whether to replace an existing output table with the same name. Values: TRUE | FALSE.
levels.casOut.replicationSpecifies the number of redundant copies of the output table (integer).
levels.casOut.tableRedistUpPolicySpecifies the table redistribution policy. Values: "DEFER" | "NOREDIST" | "REBALANCE".
levels.casOut.threadBlockSizeSpecifies the thread block size for the output table (64-bit integer).
levels.casOut.timeStampSpecifies a timestamp for the output table (string).
levels.casOut.whereSpecifies WHERE expressions for subsetting the output table.
levels.rolesSpecifies the roles of each input table variable for this level of the hierarchy.
levels.roles.actualSpecifies the name of the variable that contains the actual values. Default: "ACTUAL".
levels.roles.errorSpecifies the name of the variable that contains the prediction errors. Default: "ERROR".
levels.roles.nameSpecifies the name of the variable that contains the name of the series. Default: "_NAME_".
levels.roles.predictSpecifies the name of the variable that contains the predicted values. Default: "PREDICT".
levels.tableSpecifies the forecast input table for this level of the hierarchy. Alias: inputTable. Required.
levels.table.caslibSpecifies the caslib for the input table. Defaults to the active caslib.
levels.table.computedOnDemandWhen set to True, creates computed variables when the table is loaded instead of when the action begins. Alias: compOnDemand. Default: FALSE.
levels.table.computedVarsSpecifies the names of the computed variables to create. If not specified, all variables from `computedVarsProgram` are included. Alias: compVars.
levels.table.computedVars.formatSpecifies the format to apply to the variable.
levels.table.computedVars.formattedLengthSpecifies the length of the format field plus the length of the format precision.
levels.table.computedVars.labelSpecifies the descriptive label for the variable.
levels.table.computedVars.nameSpecifies the name for the variable. Required.
levels.table.computedVars.nfdSpecifies the length of the format precision.
levels.table.computedVars.nflSpecifies the length of the format field.
levels.table.computedVarsProgramSpecifies an expression for each computed variable. Alias: compPgm.
levels.table.dataSourceOptionsSpecifies data source options. Aliases: options, dataSource.
levels.table.groupByModeSpecifies how to create groups. Values: "NOSORT" (default: groups data without sorting on each machine, then on controller) | "REDISTRIBUTE" (transfers rows between nodes for ordering, slower).
levels.table.importOptionsSpecifies settings for reading a table from a data source. Alias: import. (See common `importOptions` parameter for details).
levels.table.nameSpecifies the name of the input table. Required.
levels.table.singlePassWhen set to True, does not create a transient table on the server. Default: FALSE.
levels.table.varsSpecifies the variables to use in the action.
levels.table.vars.formatSpecifies the format to apply to the variable.
levels.table.vars.formattedLengthSpecifies the length of the format field plus the length of the format precision.
levels.table.vars.labelSpecifies the descriptive label for the variable.
levels.table.vars.nameSpecifies the name for the variable. Required.
levels.table.vars.nfdSpecifies the length of the format precision.
levels.table.vars.nflSpecifies the length of the format field.
levels.table.whereSpecifies a WHERE expression for subsetting the input data.
levels.table.whereTableSpecifies an input table containing rows to use as a WHERE filter. Applied before the input table's `where` parameter.
levels.table.whereTable.casLibSpecifies the caslib for the filter table. Defaults to the active caslib.
levels.table.whereTable.dataSourceOptionsSpecifies data source options for the filter table. (See common `dataSourceOptions` parameter for details).
levels.table.whereTable.importOptionsSpecifies settings for reading the filter table from a data source. (See common `importOptions` parameter for details).
levels.table.whereTable.nameSpecifies the name of the filter table. Required.
levels.table.whereTable.varsSpecifies the variable names to use from the filter table.
levels.table.whereTable.vars.formatSpecifies the format to apply to the variable.
levels.table.whereTable.vars.formattedLengthSpecifies the length of the format field plus the length of the format precision.
levels.table.whereTable.vars.labelSpecifies the descriptive label for the variable.
levels.table.whereTable.vars.nameSpecifies the name for the variable. Required.
levels.table.whereTable.vars.nfdSpecifies the length of the format precision.
levels.table.whereTable.vars.nflSpecifies the length of the format field.
levels.table.whereTable.whereSpecifies a WHERE expression for subsetting data from the filter table.
nThreadsSpecifies the number of threads to use for each worker node in a CAS session. Default: 0. Range: 0–32767.
timeIdSpecifies the time ID variable. Required.
Data Preparation View data prep sheet
Example Data for globalReconcile

To use the `globalReconcile` action, you typically need hierarchical forecast data. This example demonstrates how to create a sample dataset that could be used as input.

Copied!
1DATA mycas.forecasts;
2 LENGTH date 8 region $10 product $10 actual predict error 8;
3 FORMAT date date9.;
4 DO date = '01JAN2023'd to '31DEC2023'd;
5 DO region = 'East', 'West';
6 DO product = 'A', 'B', 'Total';
7 actual = rand('Normal', 100, 10);
8 predict = actual + rand('Normal', 0, 5);
9 error = actual - predict;
10 OUTPUT;
11 END;
12 END;
13 END;
14RUN;

Examples

This example demonstrates how to use the `globalReconcile` action to reconcile a simple two-level hierarchy of forecasts. The hierarchy consists of forecasts grouped by 'region' and 'product'.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 tsReconcile.globalReconcile
3 groupBy={'region', 'product'},
4 levels={
5 {TABLE={name='forecasts'},
6 casOut={name='reconciled_forecasts_bottom', replace=true}},
7 {TABLE={name='forecasts', where='product="Total"'},
8 casOut={name='reconciled_forecasts_top', replace=true}}
9 },
10 timeId='date';
11RUN;
Result :
The `reconciled_forecasts_bottom` table will contain the reconciled forecasts for each region and product, and the `reconciled_forecasts_top` table will contain the reconciled forecasts for the 'Total' product, ensuring consistency across the hierarchy levels.

This comprehensive example illustrates the use of `globalReconcile` with custom variable roles, data filtering (using both `where` and `whereTable`), and output table options for a more complex forecasting hierarchy. It demonstrates how to handle input tables where actuals, predictions, and errors are named differently, and how to apply conditions to both the main input and a filtering table.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 /* Create a filtering table for specific regions */
3 DATA mycas.region_filter;
4 LENGTH region $10;
5 region = 'East'; OUTPUT;
6 region = 'South'; OUTPUT;
7 RUN;
8 
9 /* Assume 'forecast_data' contains forecast results with custom column names */
10 /* Also assume there's a 'forecast_summary' table for an aggregated level */
11 DATA mycas.forecast_data;
12 LENGTH forecast_date 8 region_group $10 item_code $10 actual_sales predict_sales pred_error 8;
13 FORMAT forecast_date date9.;
14 DO forecast_date = '01JAN2023'd to '31MAR2023'd BY 7;
15 DO region_group = 'East', 'West', 'North', 'South';
16 DO item_code = 'Item1', 'Item2', 'Total_Items';
17 actual_sales = rand('Normal', 200, 20);
18 predict_sales = actual_sales + rand('Normal', 0, 10);
19 pred_error = actual_sales - predict_sales;
20 OUTPUT;
21 END;
22 END;
23 END;
24 RUN;
25 
26 DATA mycas.forecast_summary;
27 LENGTH forecast_date 8 region_group $10 actual_sales predict_sales pred_error 8;
28 FORMAT forecast_date date9.;
29 DO forecast_date = '01JAN2023'd to '31MAR2023'd BY 7;
30 DO region_group = 'East', 'West', 'North', 'South';
31 actual_sales = rand('Normal', 500, 50);
32 predict_sales = actual_sales + rand('Normal', 0, 20);
33 pred_error = actual_sales - predict_sales;
34 OUTPUT;
35 END;
36 END;
37 RUN;
38 
39 tsReconcile.globalReconcile
40 groupBy={'region_group', 'item_code'},
41 levels={
42 /* Bottom level with custom roles and input table filtering */
43 {TABLE={name='forecast_data',
44 where="item_code ne 'Total_Items'",
45 whereTable={name='region_filter'}},
46 roles={actual='actual_sales', predict='predict_sales', error='pred_error', name='item_code'},
47 casOut={name='reconciled_detailed', replace=true,
48 promote=true, label='Reconciled Detailed Forecasts'}},
49 
50 /* Middle level - aggregated by region_group */
51 {TABLE={name='forecast_summary'},
52 roles={actual='actual_sales', predict='predict_sales', error='pred_error'},
53 casOut={name='reconciled_region_summary', replace=true}},
54 
55 /* Top level - overall total, inferred from 'forecast_summary' if 'item_code' is removed from groupBy */
56 {TABLE={name='forecast_summary', where='region_group ne "East"'},
57 roles={actual='actual_sales', predict='predict_sales', error='pred_error'},
58 casOut={name='reconciled_overall_total', replace=true,
59 maxMemSize=104857600 /* 100MB */}}
60 },
61 nThreads=4, /* Using 4 threads for processing */
62 timeId='forecast_date';
63RUN;
Result :
The `reconciled_detailed` table will contain forecasts reconciled at the item level, filtered by both `item_code` and `region_group` (from `region_filter`). The `reconciled_region_summary` table will provide reconciled forecasts aggregated by `region_group`. Finally, `reconciled_overall_total` will contain the top-level reconciled forecasts, excluding the 'East' region, demonstrating how to apply filters at different levels and manage output properties like promotion and memory limits.

FAQ

What is the globalReconcile Action?
What is the 'groupBy' parameter?
What is the 'levels' parameter?
What is the 'casOut' sub-parameter under 'levels'?
What is the 'roles' sub-parameter under 'levels'?
What is the 'table' sub-parameter under 'levels'?
What is the 'nThreads' parameter?
What is the 'timeId' parameter?