BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sami
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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

1 REPLY 1
BrunoMueller
SAS Super FREQ

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 5125 views
  • 3 likes
  • 2 in conversation