BookmarkSubscribeRSS Feed
sam369
Obsidian | Level 7

Hello Sir,

I have a question in proc reporting.

final dataset looks like

term              acterm                 pterm                   trt1                 trt2            total  

aterm1            aterm1                                            99                    98             197

  pterm1          aterm1                   pterm1                 1                      2               3

  pterm2          aterm1                   pterm2                 5                      6               11

  pterm3          aterm1                   pterm3                 2                     4                 6

1

aterm2            aterm2                                             220                210               450

pterm4           aterm2                   pterm4

pterm5            aterm2                 pterm5

pterm6            aterm2                 pterm6

pterm7            aterm2                 pterm7

pterm8            aterm2                 pterm8

...                   .........                .........

...                       ......                 ........

pterm10            .........                 pterm10                 10              20                   30

2

aterm3

pterm11

pterm12

.....

1450 term(aterm80 ,under aterm pterm are presented)

My question is gor the values and everything right. But in RTF i need to present like only term, trt1 trt2 total

in term variable first row is aterm and intended with pterm,

Im using proc report to produce rtf.

the final ouput is like break after aterm/skip(i mean i need a space highlghted in red color(1,2) these represents space

in term variable if page break before the pterm1,pterm4 then aterm1 are also show in next page

RFT output;

aterm1

   pterm1

   pterm2

   pterm3

(need space)

                                                                    

aterm2

    pterm4

                                                           page break(if page break is happens like this)

in next pagee

  aterm2(cont)

   pterm5

   pterm6

  p term7

(need space)

aterm3                                                    pagebreak(if it happens like this) this line should be moved into next page

in next page

aterm3

  pterm8

  pterm9

.......

I hope i explained clearly. Please help me out

Thanks in advance

Sam

10 REPLIES 10
sam369
Obsidian | Level 7

Hello Sir,

I am wondering if some body will give helpful tip on this issue. This is all about line break...the data  is all about AETERMS and PTERMS....im using break after ,but some where in the RTF. aterm in one page and pterms in another page....

Thanks

Sam

art297
Opal | Level 21

While proc report is definitely a SAS procedure, I think you will be more likely to get a response by moving your question over to the "ods and reporting" forum.

sam369
Obsidian | Level 7

Thanks Art!!!!!!

I will try there and post my question over there.

Thanks

Surya

Ksharp
Super User

I am late.

From what you post, It looks like you need to pre-process your original data firstly to make a break variable .

I am not sure whether the following is what you need.

data temp;
infile datalines truncover dlm=' ';
input term    $          acterm     $            pterm   $                trt1                trt2            total   ;
datalines;
aterm1            aterm1                   .                         99                    98             197
pterm1          aterm1                   pterm1                 1                      2               3
pterm2          aterm1                   pterm2                 5                      6               11
pterm3          aterm1                   pterm3                 2                     4                 6
aterm2            aterm2                     .                        220                210               450
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
aterm3
pterm11
pterm12
;
run;
data temp;
 length group $ 10;
 retain group;
 set temp;
 if term eq: 'aterm' then group=term;
run;
ods listing close;
ods rtf file='c:\x.rtf' style=sasweb;
proc report data=temp nowd;
column group term acterm  pterm  trt1  trt2  total   ;
define group/noprint group;
break after group/page;
run;
ods rtf close;
ods listing;


Ksharp

sam369
Obsidian | Level 7

Thanks Sharp for your reply...

But unfortunately that is not what i am looking!!!!! This is all about the pagination issue.. whic commonly occure in socterms and ptterm...Because ptterms are not in even so it is hard to break exactly where we want..

suppose the final dataset is like this

atc/pterm                                                                                  atcterm                               pterm

ADRENERGIC AND DOPAMINERGIC AGENTS   

      EPHEDRINE

      MIDODRINE

     COMBIVENT

     EPALRESTAT      

    NOREPINEPHRINE       

    EPHEDRINE

                                                                (suppose the page break is here in this page)

ADRENERGIC AND DOPAMINERGIC AGENTS (CONT) ( i need like this in next page)

    DFASDFAS

    DSFASDFA

     DSFASDFWE

    EWRWE

      EWRWQER

      KJLKLKJI

i am unable to break exactly because PTERM are unpredictiable.... Some have only 1 for under atc and some have more than 20 under ATC term.....if it break in between ...i need to so on the next page.......atcterc(CONT)

Thanks

Sam

Cynthia_sas
SAS Super FREQ

Hi:

  This question was reposted twice to the ODS and Base SAS Reporting forum. Several suggestions and links to previous postings have been made...most recently this post: http://communities.sas.com/message/112819#112819

  Rather than post more here, it would be more useful to post in the ODS forum, which is more appropriate to this question.

cynthia

Ksharp
Super User

It is really horrible. Cynthia maybe have a better way.

data temp;
infile datalines truncover dlm=' ';
input term    : $20.          acterm     $            pterm   $                trt1                trt2            total   ;
datalines;
aterm1            aterm1                   .                         99                    98             197
pterm1          aterm1                   pterm1                 1                      2               3
pterm2          aterm1                   pterm2                 5                      6               11
pterm3          aterm1                   pterm3                 2                     4                 6
aterm2            aterm2                     .                        220                210               450
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
aterm3
pterm11
pterm12
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
pterm4           aterm2                   pterm4
pterm5            aterm2                 pterm5
pterm6            aterm2                 pterm6
pterm7            aterm2                 pterm7
pterm8            aterm2                 pterm8
pterm10            .                pterm10                 10              20                   30
;
run;
data temp;
 set temp;   
 length keep_term $ 20; retain keep_term;
 if term eq: 'aterm' then  do;a+1; keep_term=term;end;
 count+1;
run;



data temp;
 set temp;
 by a notsorted;
 /*in my code every page of rtf contains 36 lines
  You need to adjust it according to your style */
  if mod(count,35)=1 and count ne 1 and not last.a then do;  
   _term=term ; _acterm=acterm;  _pterm=pterm; _trt1=trt1; _trt2=trt2 ; _total=total;
     call missing(of  acterm pterm trt1 trt2 total);term=cats(keep_term,'(count)');output;
      term=_term ; acterm=_acterm;  pterm=_pterm; trt1=_trt1; trt2=_trt2 ; total=_total;
      output;
      end; 
    else output; 
run;

data temp;
 set temp;
 if index(term, '(count)') then group+1;
run;


title 'Tile';
ods listing close;
ods rtf file='c:\x.rtf' style=sasweb;
proc report data=temp nowd ;
column  term acterm  pterm  trt1  trt2  total   group ;
define group/order;
compute term;
if term eq: 'aterm' then call define(_col_,'style','style={foreground=blue}' );
endcomp;
break after group/page;
run;
ods rtf close;
ods listing;



Ksharp

sam369
Obsidian | Level 7

Hi Sharp,

I really appriciated with your explination. i tried with your example. there is still some mis-breaking in the page. So due to the insufficent time.. my frnd helped me in this situation. It worked. But i didnt understand his code ..what he did it. i am pasting his code here ..could expalin me what exaxtly is going. Thank in advance

proc sort data=fulltable;
     by atcdesc cmterm;
     *where cmterm is not null or term='Subjects with >=1 Concomitant Med';

     data fulltable;
     set fulltable   ;
     by atcdesc cmterm;

     retain newsrt pg ;
      if _N_=1 then order=1;
      else order + 1;

     if first.atcdesc then linwipg+1;
     linwipg+1;
     test=length(term);
     if length(term)>60  or index(term,'!')>0 then linwipg+1;
     if length(term)>120 then linwipg+1;
     if length(term)>180 then linwipg+1;
     if length(term)>240 then linwipg+1;

     if linwipg>26 then do;
       newsrt+1;
       pg+1;
       linwipg=0;
     if length(term)>60  or index(term,'!')>0 then linwipg+1;
     if length(term)>120 then linwipg+1;
     if length(term)>180 then linwipg+1;
     if length(term)>240 then linwipg+1;
     end;

     if linwipg>26  then do;
       pg+1;
       linwipg=0;
     end;

    if linwipg>24 and first.atcdesc  then do;
       pg+1;
       linwipg=0;
     end;
     run;


     data final;
     length rptatc lstatc $100.;
     set fulltable;
     by pg  atcdesc linwipg ;

     retain rptatc lstatc ;

     if first.pg then do;
        if lstatc = atcdesc  and order ne 1 then  rptatc = strip(atcdesc)||' (cont)';
        else rptatc=' ';
     end;
     else if first.atcdesc then rptatc=' ';


     output;
     lstatc=atcdesc;

     run;

Thanks

Surya

Cynthia_sas
SAS Super FREQ

Hi:

  It looks like your friend took a slightly different approach. He is reading through the data and incrementing a counter (LINWIPG), then he is also creating a "fake page break variable" called PG -- he is doing this in the FULLTABLE dataset. Then, when he created the FINAL dataset, he added the string (cont) to the ATCDESC variable, based on the value of the PG variable combined with the value of the ORDER variable.

  Perhaps you can ask your friend to walk you through his logic. In this case, he did all his manipulations in a DATA step program and probably there was no extra COMPUTE block needed in your PROC REPORT code. IF you run a PROC PRINT on the FINAL dataset, before your PROC REPORT and carefully examine the code, you should be able to figure out how your friend manipulated the data to achieve your desired result.

cynthia

ods listing;

  

proc print data=final noobs;

  var pg linwipg order atcdesc rptatc lstatc;

run;

  

ods listing close;

Ksharp
Super User

It is hard to say something without seeing your real data.

My code is designed on the data you posted. If your real data is not like it. My code will not work.

Ksharp

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 1531 views
  • 0 likes
  • 4 in conversation