DATA Step, Macro, Functions and more

Allignment issue when using Proc report with different font

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

Allignment issue when using Proc report with different font

Hi SAS experts,

 

The following program works perfect when "style(column)={asis=on font=('Courier New',8pt) background=white};" is specified in the macro. But after the font is changed to Arial, like, ' "style(column)={asis=on font=('Arial',9pt) background=white};". It can't be alligned any more. Please help! Thank you in advance.

 

 
%macro Lpagenum(filein, fileout);
  data _numpage;
    retain numpages 0;
    infile "&filein" length = vlg;
    input @1 line $varying134. vlg;
    if _n_ =1 then call symput("Ltitle1",line);
    if index(upcase(line), upcase("Page X of X")) > 0 then numpages + 1;
    call symput("numofpages",compress(put(numpages,5.)));
  run;

  data _odsprn;
    retain num 1 pageno 0 lineno 0;
    length line $134.;
    infile "&filein" length = vlg end = fin;
    n=_n_;
    input @1 line $varying134. vlg;

    if upcase(substr(line, 1, length(line))) = upcase(substr("&Ltitle1", 1)) then put _page_;
    point = index(upcase(line),upcase("Page X of X"));

    if point > 0 then do;
      if &numofpages > 0 then do;
        line = trim(substr(line, 1, point + 4)) ||" "|| compress(put(compress(num), 8.))||" of &numofpages";
         linelen=length(trim(line));
         line=trim(line)||repeat(" ",134-linelen-38)||"Data Last Modified: &moddate.";
          end;
      else line = substr(line, 1, point - 1);
      num + 1;
    end;

    if 5>index(line,trim("&Ltitle1"))>0 then do;
       pageno+1;
       lineno=0;
       line="&Ltitle1";
    end;

    lineno+1;
  run;

  proc sort data=_odsprn;
    by pageno n;
  run;

  ods rtf file="&fileout" style=hpeg headery=720 footery=720;
  options orientation=landscape;

  ods listing close;
  proc report data=_odsprn nowd ls=134 ps=49
              style(report)={asis=on just=center cellpadding=0 frame=void rules=none}
/*              style(column)={asis=on font=('Courier New',8pt) background=white};*/
              style(column)={asis=on font=('Arial',9pt) background=white};
    column pageno line;
        define pageno / noprint group;
        define line   /" "  width=134;
        break after pageno / page;
  run;
  ods rtf close;
  ods listing;
%mend Lpagenum;

proc printto new file="&OUTDIR.\TABLES_TEMP.rtf";
run;
proc report data =sashelp.cars nowd center headline headskip split='*'    ps=52 ls=134;
column model DriveTrain origin type Horsepower Weight length;
define model/left width=40;
define DriveTrain/left width=10;
define origin/left width=10;
define type/left width=10;
define horsepower/left width=10;
define weight/left width=10;
define length/left width=10;

  compute before _page_;
          line @1 "sponsor" @109 "Page X of X";
          line @1 "protocol" ;
          line "  ";
          line @50 "ttl1";
          line @50 "ttl2";
          line @50 "ttl3";
          line @1 134*"_";
          line "  ";
    endcomp;

run;
quit;
proc printto; run;


%Lpagenum(&OUTDIR.\tables_temp.rtf, &OUTDIR.\test&OUTNAME.);


Accepted Solutions
Solution
‎05-17-2017 09:49 PM
Frequent Contributor
Posts: 89

Re: Allignment issue when using Proc report with different font

Posted in reply to fbl204653

Part of the problem may be that Courier New is a fixed-width font, while Arial is a proportional font.  The PROC REPORT code looks like it's set up for a fixed-width font. 

 

http://home.myfairpoint.net/vzenu5ot/portfolio/sg_items/mono_propor_font_example.htm has a couple of examples that show the difference between a fixed-width font and a proportional font. 

View solution in original post


All Replies
Solution
‎05-17-2017 09:49 PM
Frequent Contributor
Posts: 89

Re: Allignment issue when using Proc report with different font

Posted in reply to fbl204653

Part of the problem may be that Courier New is a fixed-width font, while Arial is a proportional font.  The PROC REPORT code looks like it's set up for a fixed-width font. 

 

http://home.myfairpoint.net/vzenu5ot/portfolio/sg_items/mono_propor_font_example.htm has a couple of examples that show the difference between a fixed-width font and a proportional font. 

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 145 views
  • 0 likes
  • 2 in conversation