BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
beamer108
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
VincentRejany
SAS Employee

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()

 

View solution in original post

4 REPLIES 4
VincentRejany
SAS Employee

You can either add a calculated field

VincentRejany_0-1616402796963.png

 

 

 

an "expression node" with the following code

 

pre processing

real myTotal

 

expression

myTotal = toreal(total_sales) + toreal(total_income)

beamer108
Quartz | Level 8

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)

beamer108_0-1616415535320.png

 

VincentRejany
SAS Employee

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()

 

beamer108
Quartz | Level 8
Thank you SOOO much! This is amazing. I had almost convinced myself that it wasn't possible. Thank you!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 4 replies
  • 1002 views
  • 1 like
  • 2 in conversation