Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!

Indenting rows selectively in PROC REPORT

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Indenting rows selectively in PROC REPORT

Hi All, 

I am using PROC REPORT to generate a meeting agenda. 

The major agenda topics are noted with whole numbers, 1.0, 2.0, 3.0, ect....

while the descriptive information is noted with decimals, 3.1, 4.1.

Not every major topic has descriptive information.

I'd like to INDENT the descriptive information only. 

Is there a way to do that?

Here is some sample data and code.

Thank you !

 


data Agenda_2;
input No Text1 $50. ;
datalines ;
1 Members and Attendance
2 Review Minutes of Previous Meeting
3 Interesting First Topic
3.1 All there is to be said about this extremely Interesting First Topic, indeed
4 Interesting Second Topic
4.1 A copious font of knowledge concerning this extremely Interesting second Topic, indeed
5 Interesting third Topic
6 Interesting fourth Topic
run;

 

ods listing close;
options papersize=letter orientation=portrait ps=80 ls=100 nocenter
LEFTMARGIN=0.75in RIGHTMARGIN=0.75in TOPMARGIN=1.0in BOTTOMMARGIN=0.75in
nodate nonumber;
ods rtf file="&tabout.\AG_PandT &datetime..rtf" ;

proc report data= Agenda_2 NOWD
style(report) = [bordercolor=white]
style(column) = [bordercolor=white]
style(header) = [bordercolor=white background = white]
style(summary) = [bordercolor=white] ;
column no text1 ;
define no / ' ' style(column)={cellwidth= 0.5 in} format=4.1 ;
define Text1 / ' ' style (column)={cellwidth=6.0 in} ;
title1 j=c "Agenda";
title2 j=c "All The Interesting Things That Have Happened";
title3 j=c "Since We Last Had THis Meeting";
run;

ODS _all_ close ;


Accepted Solutions
Solution
‎07-08-2018 09:26 AM
SAS Super FREQ
Posts: 9,436

Re: Indenting rows selectively in PROC REPORT

Posted in reply to rmacarthur

HI:
You can do indenting a variety of ways -- either indent= or leftmargin= as a style= override. There have been previous forum postings about it. I showed an example of how to do it in this paper: http://www2.sas.com/proceedings/forum2008/173-2008.pdf -- the paper showed specifically using ODS RTF with the JOURNAL style and the use of a helper variable to do the indenting.

If I understand what you're indicating, it sounds like you want every x.1 line to be indented? Is that correct? So in the above data that you posted, you'd only indent 3.1 and 4.1?

If that's the case, I'd probably use a CALL DEFINE for TEXT1 and set the style based on testing the value of NO.

 

I changed your program that reads the data a bit. Your text was longer than $50. LS and PS have no impact on ODS RTF -- they are LISTING destination options. I used your NO variable to make TMPVAR, as a Helper variable and specified NO as an ORDER item. TMPVAR is tested for the value gt 0 to change the indent level using the LEFTMARGIN style attribute. I changed the way you got rid of borders by just using the JOURNAL style and turning off the 2 lines that come with JOURNAL style.

 

data Agenda_2;
length text1 $90;
infile datalines dlm=',' dsd;
input No Text1 $ ;
datalines ;
1, "Members and Attendance"
2, "Review Minutes of Previous Meeting"
3, "Interesting First Topic"
3.1, "All there is to be said about this extremely Interesting First Topic, indeed"
4, "Interesting Second Topic"
4.1, "A copious font of knowledge concerning this extremely Interesting second Topic, indeed"
5, "Interesting third Topic"
6, "Interesting fourth Topic"
run;

options papersize=letter orientation=portrait nocenter
    LEFTMARGIN=0.75in RIGHTMARGIN=0.75in 
    TOPMARGIN=1.0in BOTTOMMARGIN=0.75in
    nodate nonumber;
ods rtf file="/home/cynthia.zender/all_output/indent.rtf" 
  style=journal;

proc report data= Agenda_2 NOWD
   style(report)={rules=none frame=void cellspacing=0};
column no text1 ;
define no / order ' ' style(column)={cellwidth= 0.5 in} format=4.1 ;
define Text1 / display ' ' style (column)={cellwidth=6.0 in} ;
compute text1;
   tmpvar = no - int(no);
   if tmpvar gt 0 then do;
      call define(_col_,'style','style={leftmargin=.15in}');
   end;
endcomp;
title1 j=c "Agenda";
title2 j=c "All The Interesting Things That Have Happened";
title3 j=c "Since We Last Had THis Meeting";
run;

ODS rtf close ;



Cynthia

View solution in original post


All Replies
Regular Contributor
Posts: 170

Re: Indenting rows selectively in PROC REPORT

Posted in reply to rmacarthur
Solution
‎07-08-2018 09:26 AM
SAS Super FREQ
Posts: 9,436

Re: Indenting rows selectively in PROC REPORT

Posted in reply to rmacarthur

HI:
You can do indenting a variety of ways -- either indent= or leftmargin= as a style= override. There have been previous forum postings about it. I showed an example of how to do it in this paper: http://www2.sas.com/proceedings/forum2008/173-2008.pdf -- the paper showed specifically using ODS RTF with the JOURNAL style and the use of a helper variable to do the indenting.

If I understand what you're indicating, it sounds like you want every x.1 line to be indented? Is that correct? So in the above data that you posted, you'd only indent 3.1 and 4.1?

If that's the case, I'd probably use a CALL DEFINE for TEXT1 and set the style based on testing the value of NO.

 

I changed your program that reads the data a bit. Your text was longer than $50. LS and PS have no impact on ODS RTF -- they are LISTING destination options. I used your NO variable to make TMPVAR, as a Helper variable and specified NO as an ORDER item. TMPVAR is tested for the value gt 0 to change the indent level using the LEFTMARGIN style attribute. I changed the way you got rid of borders by just using the JOURNAL style and turning off the 2 lines that come with JOURNAL style.

 

data Agenda_2;
length text1 $90;
infile datalines dlm=',' dsd;
input No Text1 $ ;
datalines ;
1, "Members and Attendance"
2, "Review Minutes of Previous Meeting"
3, "Interesting First Topic"
3.1, "All there is to be said about this extremely Interesting First Topic, indeed"
4, "Interesting Second Topic"
4.1, "A copious font of knowledge concerning this extremely Interesting second Topic, indeed"
5, "Interesting third Topic"
6, "Interesting fourth Topic"
run;

options papersize=letter orientation=portrait nocenter
    LEFTMARGIN=0.75in RIGHTMARGIN=0.75in 
    TOPMARGIN=1.0in BOTTOMMARGIN=0.75in
    nodate nonumber;
ods rtf file="/home/cynthia.zender/all_output/indent.rtf" 
  style=journal;

proc report data= Agenda_2 NOWD
   style(report)={rules=none frame=void cellspacing=0};
column no text1 ;
define no / order ' ' style(column)={cellwidth= 0.5 in} format=4.1 ;
define Text1 / display ' ' style (column)={cellwidth=6.0 in} ;
compute text1;
   tmpvar = no - int(no);
   if tmpvar gt 0 then do;
      call define(_col_,'style','style={leftmargin=.15in}');
   end;
endcomp;
title1 j=c "Agenda";
title2 j=c "All The Interesting Things That Have Happened";
title3 j=c "Since We Last Had THis Meeting";
run;

ODS rtf close ;



Cynthia

Contributor
Posts: 23

Re: Indenting rows selectively in PROC REPORT

Posted in reply to Cynthia_sas

Cynthia and Paul, 

Spot on, thank you both. 

Yes, I was looking to just indent to rows where no=#.1, and now better understand the "call define" feature.

Much appreciated, 

Robert 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 222 views
  • 0 likes
  • 3 in conversation