Your SAS programs, embedded in web apps and elsewhere

Code for line not displaying anything

Posts: 0

Code for line not displaying anything

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;


break after department /summarize;
Rbreak after / summarize;
compute after;
line "Total : " N;

Thank you so much in advance!
Posts: 8,743

Re: Code for line not displaying anything

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:
define sales/ noprint;
define sales/ sum noprint;
define sales/ analysis sum noprint;
define sales/ analysis noprint;

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

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

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:

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.

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.
Posts: 0

Re: Code for line not displaying anything

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....
Posts: 8,743

Re: Code for line not displaying anything

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ᰇ) 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.

Posts: 0

Re: Code for line not displaying anything

Thanks, Cynthia,

As always, your contributions are very appreciated. I'll "beat up" my project some more and try to apply your advice.
Ask a Question
Discussion stats
  • 4 replies
  • 2 in conversation