Hi all, i have used PROC PRINT to generate a report that i want. So far i managed to get my expected results.
As you can see, i got a SUM after the last row. What i want now is to add the word "SUM" below "Java Programmer". Is there a way to do so? My code is as below:
proc print data=WORK.JOIN2BCAE obs='No.' label; title 'Alfred Employee Bank Commitment/Financial Status'; var X_BCAE_NAME X_BCAE_POSITION X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum; label X_BCAE_NAME = 'Name' X_BCAE_POSITION = 'Position' X_BCAE_INCOME = 'Income' X_BCAE_CARLOAN = 'Car Loan Installment' X_BCAE_MORTGAGE = 'Mortgage' X_BCAE_CASHFLOW = 'Cash Flow' newsum = 'Maximum New Loan'; sum X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum; RUN;
PROC PRINT is a very simple procedure with minimal features. You can't do more with SUM than you already did.
I recommend you take a look at the REPORT procedure for more flexible report creation.
There you can set values for columns in a compute block for the time when a group switch occurs:
define X_BCAE_POSITION / display 'Position'; compute X_BCAE_POSITION; if _break_='RBREAK' then do; call define("X_BCAE_POSITION", 'style', 'style=[pretext="Sum"]'); end; endcomp;
You can use the Wizard in Enterprise Guide to get the basic code for the PROC REPORT step and then experiment with manipulating the summary line
This is sample code for SASHELP.CLASS:
proc report data=SASHELP.CLASS nowd; column Name Sex Age, SUM=Age_SUM Height, SUM=Height_SUM Weight, SUM=Weight_SUM; define Name / group 'Name' missing; compute Name; if _break_ eq ' ' then do; if Name ne ' ' then hold1=Name; end; if upcase(_break_)="NAME" then do; call define("Name", 'style', 'style=[pretext="Zwischensumme "]'); end; endcomp; define Sex / display 'Sex' missing; compute Sex; if _break_ eq ' ' then do; if Sex ne ' ' then hold2=Sex; end; if _break_='_RBREAK_' then do; call define("Sex", 'style', 'style=[pretext="Sum"]'); end; endcomp; define Age / analysis SUM 'Age' missing; define Height / analysis SUM 'Height' missing; define Weight / analysis SUM 'Weight' missing; rbreak after / summarize; run; quit;
It is also very confusing for me, as I'm more of a data architect than report creator, so I rarely get to tinker with it.
All I did was create a report with the wizard in EG and then play around with the statements in the compute block until I got the desired result.
So you see, even for seasoned SAS users the helpers in EG can be very convenient at times.
I don't think that SUMLABEL does what he wants. SUMLABEL only causes the Label of the BY variable to be displayed in the summary line (instead of the simple variable name).
Since he wants to display some arbitrary text in a column of a non-BY variable, this won't help.
From his example, I deduce that X_BCAE_POSITION (the column where he wants the "Sum" to be located) is not a BY variable.
Ah, I see that's new with 9.4. If the OP is at an earlier release, this may be the cause for the ERRORs.
I still don't think it gives one the necessary freedom in selecting where (which column) to put the labels. That's why PROC REPORT may be the (only) way to go.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.