DATA Step, Macro, Functions and more

PROC REPORT: ADD Blank Line with condition

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

PROC REPORT: ADD Blank Line with condition

Hi,

 

I am facing problem a problem to add blank line after certain condition:

 

ROC REPORT DATA=final_report2 NOWD MISSING HEADLINE SPACING=2 SPLIT='~';
  COLUMN (cntr Country sort Variable Stat DummyRed DummyBlue Total);
  DEFINE cntr /    ORDER  ORDER=data WIDTH=20 FLOW NOPRINT;
  DEFINE Country /'Country' display WIDTH=10 FLOW STYLE=[cellwidth=2 cm];
    DEFINE sort / ORDER  ORDER=internal noprint;
    DEFINE Variable /'Variable' ORDER ORDER=data WIDTH=20 FLOW;
/*    DEFINE sort1 / ORDER NOPRINT;*/
    DEFINE Stat / 'Stat'  WIDTH=20 FLOW;
    DEFINE DummyRed/'Dummy Red~N=658' WIDTH=20 FLOW STYLE=[ASIS=on cellwidth=3 cm];
    DEFINE DummyBlue/'Dummy Blue~N=656' WIDTH=20 FLOW STYLE=[ASIS=on cellwidth=3 cm];
    DEFINE Total/'Total~N=1773' WIDTH=20 FLOW RIGHT STYLE=[cellwidth=2.5 cm];
    BREAK AFTER cntr / PAGE;
 
 COMPUTE after sort;
   IF sort in (1 2 3) then LINE @1 ' ';
 ENDCOMP;

RUN;

 

-There are 5 Numeric Sort at Dataset : SORT = 1 , 2, 3, 4, 5 but i want to put line only after SORT (1, 2, 3)?

-But above BOLD Marked not working?

 

Do you now why?

 

Rwgards

Sami


Accepted Solutions
Solution
‎02-14-2016 01:19 AM
SAS Super FREQ
Posts: 708

Re: PROC REPORT: ADD Blank Line with condition

hi Sami

 

Proc REPORT will always created break lines when using the LINE statement in a COMPUTE block. there is also the follwoing restriction:

Restrictions: This statement is valid only in a compute block that is associated with a location in the report.
You cannot use the LINE statement in conditional statements (IF-THEN, IF-THEN/ELSE, and SELECT) because it is not executed until PROC REPORT has executed all other statements in the compute block.

 

see the doc for details.

 

There might me a away around this by using some inlineformatting functions.

 

Find below a sample program that illustrates this, seems to work ok, for HTML.

 

data have;
  set sashelp.class;
  sort = mod(_n_, 6);
run;

ods escapechar="~";

proc report data=have;
  column sort name sex age;
  define sort / order;
  define name / display;
  define sex / display;
  define age / display;

  compute after sort / style={fontsize=2pt };
    length msg $ 64;

    if sort in (1,2,3) then do;
      msg = "~{newline 10}";
    end;
    else do;
      msg = "~{newline 0}";
    end;

    line msg $64.;
  endcomp;
run;

Bruno

View solution in original post


All Replies
Solution
‎02-14-2016 01:19 AM
SAS Super FREQ
Posts: 708

Re: PROC REPORT: ADD Blank Line with condition

hi Sami

 

Proc REPORT will always created break lines when using the LINE statement in a COMPUTE block. there is also the follwoing restriction:

Restrictions: This statement is valid only in a compute block that is associated with a location in the report.
You cannot use the LINE statement in conditional statements (IF-THEN, IF-THEN/ELSE, and SELECT) because it is not executed until PROC REPORT has executed all other statements in the compute block.

 

see the doc for details.

 

There might me a away around this by using some inlineformatting functions.

 

Find below a sample program that illustrates this, seems to work ok, for HTML.

 

data have;
  set sashelp.class;
  sort = mod(_n_, 6);
run;

ods escapechar="~";

proc report data=have;
  column sort name sex age;
  define sort / order;
  define name / display;
  define sex / display;
  define age / display;

  compute after sort / style={fontsize=2pt };
    length msg $ 64;

    if sort in (1,2,3) then do;
      msg = "~{newline 10}";
    end;
    else do;
      msg = "~{newline 0}";
    end;

    line msg $64.;
  endcomp;
run;

Bruno

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 841 views
  • 2 likes
  • 2 in conversation