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

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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