BookmarkSubscribeRSS Feed
deleted_user
Not applicable
In a proc report I'm designing, I'm trying to use the line type of code to print a custom total line, however, no totals are showing in the custom total lines. If anyone is willing to scheck out my code and let me know what I am not doing correctly, I would sure appreciate it. Here's the code:

PROC REPORT data = sfile1 spacing = 1 style(Header)={font_size=2.0 font_weight=medium} split='*' missing;
column Department Ten Position_Title Gender N ETHNICITY Name Service_date
mcount fcount whitecount blackcount hispcount asiancount indiancount othercount recordcount;

define Department /group "DEPARTMENT" style=[just=l font_weight=demi_bold font_Size=2.0];
define Ten /group "TENURE" style=[just=l font_weight=demi_bold font_Size=2.0];
define Position_title /group "RANK" style=[just=l font_weight=demi_bold font_Size=2.0];
define Gender /group "GENDER" style=[just=l font_weight=demi_bold font_Size=2.0];
define Ethnicity /group "ETHNICITY" style=[just=l font_weight=demi_bold font_Size=2.0];
define Name/group "NAME" style=[just=l font_weight=demi_bold font_Size=2.0];
define Service_date /group "SERVICE*DATE" style=[just=l font_weight=demi_bold font_Size=2.0];
define mcount /sum "mcount" style=[just=l font_weight=demi_bold font_Size=2.0];
define fcount /sum "fcount" style=[just=l font_weight=demi_bold font_Size=2.0];
define whitecount /sum "WHITE" style=[just=l font_weight=demi_bold font_Size=2.0];
define blackcount / noprint;
define hispcount / noprint;
define asiancount / noprint;
define indiancount / noprint;
define othercount / noprint;
define recordcount /sum "RECORDS" style=[just=l font_weight=demi_bold font_Size=2.0];

break after department / ol summarize;
compute after department;

Line @10 'TOTAL IN ' department +4 recordcount;

Line @10 'Total Males: ' Mcount ' Total Females: ' Fcount;
Line @10 'Caucasians: ' +5 whitecount;
Line @10 'Black: ' +5 Blackcount;
Line @10 'Hispanic : ' +5 Hispcount;

endcomp;

break after department /summarize;
Rbreak after / summarize;
compute after;
fcount=0;
mcount=0;
line "Total : " N;
endcomp;
run;

Thank you so much in advance!
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
In the SAS documentation for PROC REPORT, there is a topic called: "Concepts: Report Procedure". In that topic is a subsection called "Using Compound Names".

You can see other examples of using compound names in a COMPUTE block in the topic entitled, "How PROC REPORT builds a Report".

In a define statement for a numeric variable, the default usage is "analysis" with a default statistic of "sum". Therefore, all of these DEFINE statements are the same:
[pre]
define sales/ noprint;
define sales/ sum noprint;
define sales/ analysis sum noprint;
define sales/ analysis noprint;
[/pre]

If I want to calculate profit, then inside my COMPUTE block, I need to refer to sales with a compound name:
[pre]
profit = sales.sum - overhead.sum;
[/pre]

If I want to show the total sales at the break, then in my LINE statement, I still have to refer to sales.sum:
[pre]
LINE 'Profit based on Total Sales of: ' sales.sum dollar15.2;
[/pre]

And, one last comment on your program, when I am going to use ODS to create a report with PROC REPORT (as is the case with a stored process), I generally do NOT recommend the use of "character positioning" techniques, like '@10' or '+4' with PROC REPORT. That is because the results are hardly ever what you want to see -- unless you are sending output to the LISTING window and noplace else. The reason for this is that the letter 'I' takes up less space in a proportional font than the letter 'W'. So, for example, '@10' is in a different place on each of these 3 lines:
IIIIIIIIIIIIIIIIIIII
WWWWWWWWWWWWWWWWWWWW
WWWWWIIIIIWWWWWIIIII

You may have better luck with the indent= or leftmargin= attributes for style overrides with PROC REPORT if you want these supplementary lines to be somewhat indented in the COMPUTE AFTER cells.

cynthia
ps...just an added note: in Web Report Studio (and ONLY in SAS Web Report Studio), you will NOT see the result of any LINE statement in a stored process, because the SAS Report XML does not currently have a way to handle the LINE statement.
deleted_user
Not applicable
Hi, Cynthia,

I just can't get over your outstanding fount of knowledge!! Thank you so much for sharing!

Question.... if Web Report Studio doesn't deal with the LINE statement, what can I use in its place?

Again, and again, thank you so much....
Cynthia_sas
SAS Super FREQ
Hi:
It depends on what you mean -- in place of the LINE statement or in place of the PROC REPORT?

The LINE statement does not currently work with Web Report Studio. That means you have to redesign the kind of report you want. You would not be able to use the LINE statement in your current PROC REPORT. So your choices are 1) do not use that SP with Web Report Studio or 2) redesign the report so you don't need the LINE statements.

You would have to do something such as this (that I suggested to somebody else in the forum http://support.sas.com/forums/thread.jspa?messageID=7175ᰇ) of showing the detail report and then following the detail report with the summary information (without the use of LINE statements) -- you could do this with PROC PRINT or PROC REPORT for the Detail report and then PROC REPORT or PROC TABULATE for the summary section.

Or, just abandon the "detail" portion of the report and switch to PROC TABULATE, since you already have the "counters" and just generate a summary report. Or, stick with PROC REPORT, but abandon the extensive LINE statement section in favor of a second table of a slightly different view of the summarized data.

In any of the other client applications (EG, Word, Excel) you should be able to see the results of the LINE statement.

cynthia
deleted_user
Not applicable
Thanks, Cynthia,

As always, your contributions are very appreciated. I'll "beat up" my project some more and try to apply your advice.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 873 views
  • 0 likes
  • 2 in conversation