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-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

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