BookmarkSubscribeRSS Feed
Not applicable
I have a report listing information about adjunct faculty, that I want to be able to have totals show before and after details, as follows:

Position Name Account
====== ==== ======
............................................... Salaries Liquidated Difference (yes, they want these lines like this)
............................................... ====== ======= =======
............................................... 12,000 1,500 10,500

Boss..........Ralph.......... 0001

Total for WorkerB: 1
Total for Loafer....: 1
Total for Boss.....: 1

Total for Account 1234 : 2
Total for Account 0001 : 1

I've tried a few things, but nothing seems to work.... I tried compute before, sum, compute after, and unfortunately think I've coded myself into confusion. By the way, I am not using macros to try this. If anyone has an idea (or two or three), would you mind sharing them with me?

Thank you so much!
You really CAN do this kind of report with either PROC REPORT or with a DATA step program. Interestingly enough, a similar question was recently posted to the EG forum and this posting might prove useful to you:
to help explain the SAS report procedures and how you can get a detail report and/or a summary report and/or a detail report with summary data.

For this posting, I thought it would be easier for this person to get the kind of fine control they wanted by having a DATA step program to produce output. So if you look at the example program, you would use similar logic in a DATA step program to get both "before" and "after" information around the detail rows.

However, you might not get EXACTLY the kind of indentation you want to see for those "summary" lines. That's because the kind of output that is written by default is tabular in nature -- that means the same number of columns for EVERY row on the page or a LINE statement (REPORT) whose output spans ALL the columns on the page. (Also, the row of equal signs under the headings -- probably not going to get that as stored process output -- using ODS).

Looking at your report example, I see a few things to point out. It looks to me like you might have Salaries for every worker, but do you actually have a Liquidated column for every worker. In other words -- is the 'Salaries' number the sum of each person's individual salary? What about Liquidated, what does this come from?

Generally, if you were trying to do this with PROC REPORT, it would involve a lot of compute block processing to hold values. AND, if the values, such as Liquidated and Difference are coming from a different file or are calculated from a different dataset, then to do the report with PROC REPORT might involve massaging the DATA in a DATA step program, anyway.

So, if you were going to be inside a DATA step, you may as well write out the report with one pass through the data, if possible. This kind of making counter variables to hold totals for before/after the detail might prove easier to do in DATA step where you can test for FIRST.byvar and LAST.byvar -- and, depending on how the top line of information is coming from -- you can write that out for every group or high-level BYVAR. (By FIRST.byvar, I mean that if you have BY DEPARTMENT in the data step program, you can test for the value of FIRST.DEPARTMENT and LAST.DEPARTMENT.)

You might consider contacting Tech Support for help with this one. Especially because working with PROC REPORT LINE statements in stored processes might prove problematic in Web Report Studio.

Not applicable
Hi, Cynthia,

Thanks for your help! Yes, we actually do have columns for every person related to liquidated data. Liquidated is used to account for monies expended for unforeseen / incidental expenses and as a rule, might be taken from encumbered monies. Also, yes the 'Salaries' number is the sum of each person's individual salary, by college by department by account. I'll take a look at the link you pointed me to and see what I can fathom from it. I think I'm close, but.......

Anyway, thanks once more!!



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2 in conversation