I have a datajob that writes output to an excel file. It shows multiple rows which include fields like total_sales, total_income etc. At the end of my dj I have data going to an "text file output" node which then feeds into a "Data Target (insert)" node. Is it possible to create a final summary row to the output that would give me a grand total for each of these columns?
for adding a final line with a grand total, do the following
//pre processing expression
hidden real hgrandTotalSales
hidden real hgrandTotalIncome
hgrandTotalSales = 0
hgrandTotalIncome = 0
//expression
hgrandTotalSales = hgrandTotalSales+ toreal(total_sales)
hgrandTotalIncome = hgrandTotalIncome+ toreal(total_income)
//post processing expression
service_from_date = null
total_sales = hgrandTotalSales
total_income = hgrandTotalIncome
pushrow()
You can either add a calculated field
an "expression node" with the following code
pre processing
real myTotal
expression
myTotal = toreal(total_sales) + toreal(total_income)
Im actually looking to add a row not a column. So it would look something like this: (row in red is what I am looking to add)
for adding a final line with a grand total, do the following
//pre processing expression
hidden real hgrandTotalSales
hidden real hgrandTotalIncome
hgrandTotalSales = 0
hgrandTotalIncome = 0
//expression
hgrandTotalSales = hgrandTotalSales+ toreal(total_sales)
hgrandTotalIncome = hgrandTotalIncome+ toreal(total_income)
//post processing expression
service_from_date = null
total_sales = hgrandTotalSales
total_income = hgrandTotalIncome
pushrow()
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.