BookmarkSubscribeRSS Feed
pierreol
Calcite | Level 5

Hello,

 

I need to manipulate the layout of a datagrid in a DS2 code file within a SAS Intelligent Decisioning flow.

 

The datagrid (let's all it TRANSACTIONS) is essentially parsed JSON content, which is in the following structure (with some sample data):

 

FIN_YEARJSON_KEYJSON_VALUEINDEXGROUP
2024trxTypeSAL1internal.SalesData
2024trxValue2300.501internal.SalesData
2024trxAdjustedFALSE1internal.SalesData
2024trxTypeADJ2internal.SalesData
2024trxValue1002internal.SalesData
2024trxAdjustedFALSE2internal.SalesData
2024trxTypeSAL1internal.Reversals
2024trxValue2300.501internal.Reversals
2024trxAdjustedTRUE1internal.Reversals

 

I need to transpose this (into a datagrid output called TRANSACTIONS_OUT), so the output is in the format below. Essentially the JSON_KEY should be used as the new column headers, JSON_VALUE as the value, with results grouped by the remaining columns:

 

FIN_YEARINDEXGROUPtrxTypetrxValuetrxAdjusted
20241internal.SalesDataSAL2300.50FALSE
20242internal.SalesDataADJ100FALSE
20241internal.ReversalsSAL2300.50TRUE

 

Embarrassingly, the furthest I've got is bringing the datagrid into the code file - all my other attempted code fails.

 

package "${PACKAGE_NAME}" /inline;

method execute(package datagrid TRANSACTIONS, in_out package datagrid TRANSACTIONS_OUT);

Any advice/sample code would be very much appreciated!

 

Thanks,

O

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 0 replies
  • 2380 views
  • 0 likes
  • 1 in conversation