06-03-2015 11:23 PM
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?
06-04-2015 07:41 AM
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:
length prtline $100;
if test2 = . then prtline = 'one thing';
else if test2 gt . then prtline='another';
line prtline $100.;
06-04-2015 08:01 AM
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;
if sex='F' then len=0;
compute after sex;
line @1 'sex : ' sex $varying100. len;
06-05-2015 02:09 AM
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.