The SAS Output Delivery System and reporting techniques

Proc report

Reply
Contributor
Posts: 50

Proc report

hello all

i am generating subtitles for a report and I'm using compute before _page_

line @1 test1 $20 test2 $20

i should not display test2 if it's empty  otherswIse I need to display, how can I achieve this?

SAS Super FREQ
Posts: 8,645

Re: Proc report

HI:

  You will have to use conditional logic in your COMPUTE block. But, you cannot execute LINE statements conditionally. (That is another argument against using the @20 pointer control in your LINE statement.) YOu will need to make a helper variable, a temporary variable such as PRTLINE in the example code below. Probably something like this:

COMPUTE ....;

  length prtline $100;
  if test2 = . then prtline = 'one thing';
  else if test2 gt . then prtline='another';

  line prtline $100.;
ENDCOMP:

cynthia

Grand Advisor
Posts: 9,335

Re: Proc report

There is a way to conditional execute LINE statement via format $VARYING. ;

Here is an example :


proc report data=sashelp.class nowd;
column sex weight height;
define sex/order;
define weight/display;
define height/display;
compute weight;
if sex='F' then len=0;
  else len=20;
endcomp;
compute after sex;
line @1 'sex : ' sex $varying100. len;
endcomp;
run;

Xia Keshan

SAS Super FREQ
Posts: 8,645

Re: Proc report

Hi:

  I agree that you are controlling whether the LINE output displays or not based on the value for the LEN variable. But you are NOT, technically, conditionally executing the LINE statement (the LINE statement is not on the THEN or ELSE branch). What you are doing conditionally is setting the value for the LEN variable. The fact is that when LEN is 0, the LINE statement will suppress its output -- but the LINE statement is technically, still being executed because it has to discover the value of 0 for LEN, which has the impact of suppressing any display.

  Also, based on the example the OP posted in a different location, the value of TEST2 is on a single LINE with OTHER variable values -- the example LINE statement shows TEST1. So my take on the question was that the OP still wants the TEST1 part of the line to display -- not to be suppressed altogether. That is why I posted using a "helper" variable to hold 2 different strings instead of showing the way to suppress an entire line.

cynthia

Post a Question
Discussion Stats
  • 3 replies
  • 452 views
  • 0 likes
  • 3 in conversation