BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have been given an EG process flow to maintain, and one of the code segments creates a work table by formatting character data from an input file. I need to create a new column in this table by adding 4 dollar fields to get the value for the new column.

I don't get any errors, but I don't get any output in the new column either (data column shows '.'). My code is:

(Input(put(&importfilename..Disb_1_Net_Amt,$8.),17.2)) FORMAT=DOLLAR17.2 AS Disb_1_Net_Amount,
(Input(put(&importfilename..Disb_2_Net_Amt,$8.),17.2)) FORMAT=DOLLAR17.2 AS Disb_2_Net_Amount,
(Input(put(&importfilename..Disb_3_Net_Amt,$8.),17.2)) FORMAT=DOLLAR17.2 AS Disb_3_Net_Amount,
(Input(put(&importfilename..Disb_4_Net_Amt,$8.),17.2)) FORMAT=DOLLAR17.2 AS Disb_4_Net_Amount,

/* new column */
((CALCULATED Disb_1_Net_Amount) + (CALCULATED Disb_2_Net_Amount)
+ (CALCULATED Disb_3_Net_Amount) + (CALCULATED Disb_4_Net_Amount))
FORMAT=DOLLAR17.2 AS Total_Disb_Net_Amount,

What am I doing wrong? Thanks.
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12
Does your query show data in the ...Net_Amount fields? Are they all there?

One possibility:
By using the "+" operator, if any of the component parts are missing, the result is missing. If you have missing pieces and the sum is still meaningful, use the SUM function to add them up.
deleted_user
Not applicable
That did it. Some of the Net Amount fields were null/blank '.'

The new code of

SUM(CALCULATED Disb_1_Net_Amount,CALCULATED Disb_2_Net_Amount, CALCULATED Disb_3_Net_Amount,CALCULATED Disb_4_Net_Amount) FORMAT=DOLLAR17.2 AS Total_Disb_Net_Amount,

works like a charm. Thank you.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 735 views
  • 0 likes
  • 2 in conversation