The SAS Output Delivery System and reporting techniques

"Could not locate style reference" error

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 129
Accepted Solution

"Could not locate style reference" error

I'm trying to define my own template. However, I'm getting some warnings when I run it. What am I doing wrong? The code and selected log output is below.

Thanks

CODE

proc template;

  define style Styles.BB1;

  parent = Styles.Journal;

    replace fonts /

    'TitleFont'= ("Times Roman",12pt,Bold)

    'TitleFont2'= ("Times Roman",12pt,Bold)

    'StrongFont'= ("Times Roman",10pt,Bold)

    'EmphasisFont'= ("Times Roman",10pt,Bold)

    'HeadingEmphasisFont' = ("Times Roman",10pt,Bold)

    'HeadingFont' = ("Times Roman",10pt)

    'DocFont'  = ("Times Roman",10pt)

    'footfont' = ("Times Roman",10pt)

    'FixedEmphasisFont' = ("Courier",10pt,Bold)

    'FixedStrongFont' = ("Courier",10pt,Bold)

    'FixedHeadingFont' = ("Courier",10pt,Bold)

    'BatchFixedFont' = ("Courier",10pt)

    'FixedFont' = ("Courier",10pt)

    ;

    replace color_list /

    'link' = black

    'bgH' = white

    'bgT' = white

    'bgD' = white

    'fg' = black

    ;

     replace Table from Output /

    cellpadding = 2pt

    cellspacing = 0pt

    ;

    replace Pages from Document /

      marginleft = 16

      marginright = 16

      backgroundcolor = colors('bg')

      pagebreakhtml = html('break')

      tagattr = " onload=""expandAll()"""

      liststyletype = "decimal"

     ;

  end;

run;

ods rtf file="&wealth\Wealth_trends.rtf" style=BB1;

LOG OUTPUT

NOTE: Overwriting existing template/link: Styles.Bb1

NOTE: STYLE 'Styles.Bb1' has been saved to: SASUSER.TEMPLAT

249  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

250

251  ods rtf file="&wealth\Wealth_trends.rtf" style=BB1;

WARNING: Could not locate style reference 'BB1.colors("notebg")'.

WARNING: Could not locate style reference 'BB1.colors("notefg")'.

WARNING: Could not locate style reference 'BB1.colors("bg")'.


Accepted Solutions
Solution
‎10-14-2014 11:13 PM
SAS Super FREQ
Posts: 8,820

Re: "Could not locate style reference" error

Hi:

  The REPLACE statement was "deprecated" starting with SAS version 9.2. So right off the top of my head, I would NOT recommend using the REPLACE statement at all, in your template code, unless you are still using SAS 9.1.3. And, the rule of thumb if you ARE using SAS 9.1.3 is that when you use the REPLACE statement, you should RESPECIFY all the style attributes that you want to use for that STYLE element (such as color_list) -- otherwise, you will come up with missing colors and warning messages. Starting in SAS 9.2 and higher, the preferred statement in a style template is the STYLE statement or CLASS statement, as shown in the code below.

  In addition, if you look in STYLES.JOURNAL, you will see that the COLORS element does NOT have a "bg" attribute...it has "bg2", "bg3", etc, but no "bg" and if you look in the parent of JOURNAL, styles.default, you will see the same thing. So if you want the background for the Pages to be white, then either use "bg2", which is white or just use white as the value for the attribute.

  In SAS 9.4, Windows 7, and Office 2013, this code worked for me. I added a change for HEADER and DATA -- very obviously changing the colors, so it was clear whether the new style template was being used or not.

Cynthia

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
 
proc template;
  define style Styles.BB1;
  parent = Styles.Journal;
  class fonts /
    'TitleFont'= ("Times New Roman",12pt,Bold)
    'TitleFont2'= ("Times New Roman",12pt,Bold)
    'StrongFont'= ("Times New Roman",10pt,Bold)
    'EmphasisFont'= ("Times New Roman",10pt,Bold)
    'HeadingEmphasisFont' = ("Times New Roman",10pt,Bold)
    'HeadingFont' = ("Times New Roman",10pt)
    'DocFont'  = ("Times New Roman",10pt)
    'footfont' = ("Times New Roman",10pt)
    'FixedEmphasisFont' = ("Courier",10pt,Bold)
    'FixedStrongFont' = ("Courier",10pt,Bold)
    'FixedHeadingFont' = ("Courier",10pt,Bold)
    'BatchFixedFont' = ("Courier",10pt)
    'FixedFont' = ("Courier",10pt)
    ;

  class color_list /
    'link' = black
    'bgH' = white
    'bgT' = white
    'bgD' = white
    'fg' = black
    ;
  
class header /
   foreground=purple
   textdecoration=underline
   background=lightpink;

  class data /
   foreground=cyan
   background=navy;

  class Table from Output /
    cellpadding = 2pt
    cellspacing = 0pt
    ;

  class Pages from Document /
      marginleft = 16
      marginright = 16
      backgroundcolor = colors('bg2')
      pagebreakhtml = html('break')
      tagattr = " onload=""expandAll()"""
      liststyletype = "decimal"
     ;
  end;
run;

ods rtf file="c:\temp\Wealth_trends.rtf" style=BB1;
proc print data=sashelp.shoes(obs=10);
run;
ods rtf close;


use_style_template_sas_94.png

View solution in original post


All Replies
PROC Star
Posts: 1,293

Re: "Could not locate style reference" error

Just a wild guess here.

You replaced the color_list.  Looks like there are some color names which the template expects to be defined that are missing.

If you add:

'notebg'=white

'notefg'=black

'bg'=white

to your color_list, does that help?

--Q.

Frequent Contributor
Posts: 129

Re: "Could not locate style reference" error

No. I get the same result if I add these lines.

Solution
‎10-14-2014 11:13 PM
SAS Super FREQ
Posts: 8,820

Re: "Could not locate style reference" error

Hi:

  The REPLACE statement was "deprecated" starting with SAS version 9.2. So right off the top of my head, I would NOT recommend using the REPLACE statement at all, in your template code, unless you are still using SAS 9.1.3. And, the rule of thumb if you ARE using SAS 9.1.3 is that when you use the REPLACE statement, you should RESPECIFY all the style attributes that you want to use for that STYLE element (such as color_list) -- otherwise, you will come up with missing colors and warning messages. Starting in SAS 9.2 and higher, the preferred statement in a style template is the STYLE statement or CLASS statement, as shown in the code below.

  In addition, if you look in STYLES.JOURNAL, you will see that the COLORS element does NOT have a "bg" attribute...it has "bg2", "bg3", etc, but no "bg" and if you look in the parent of JOURNAL, styles.default, you will see the same thing. So if you want the background for the Pages to be white, then either use "bg2", which is white or just use white as the value for the attribute.

  In SAS 9.4, Windows 7, and Office 2013, this code worked for me. I added a change for HEADER and DATA -- very obviously changing the colors, so it was clear whether the new style template was being used or not.

Cynthia

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
 
proc template;
  define style Styles.BB1;
  parent = Styles.Journal;
  class fonts /
    'TitleFont'= ("Times New Roman",12pt,Bold)
    'TitleFont2'= ("Times New Roman",12pt,Bold)
    'StrongFont'= ("Times New Roman",10pt,Bold)
    'EmphasisFont'= ("Times New Roman",10pt,Bold)
    'HeadingEmphasisFont' = ("Times New Roman",10pt,Bold)
    'HeadingFont' = ("Times New Roman",10pt)
    'DocFont'  = ("Times New Roman",10pt)
    'footfont' = ("Times New Roman",10pt)
    'FixedEmphasisFont' = ("Courier",10pt,Bold)
    'FixedStrongFont' = ("Courier",10pt,Bold)
    'FixedHeadingFont' = ("Courier",10pt,Bold)
    'BatchFixedFont' = ("Courier",10pt)
    'FixedFont' = ("Courier",10pt)
    ;

  class color_list /
    'link' = black
    'bgH' = white
    'bgT' = white
    'bgD' = white
    'fg' = black
    ;
  
class header /
   foreground=purple
   textdecoration=underline
   background=lightpink;

  class data /
   foreground=cyan
   background=navy;

  class Table from Output /
    cellpadding = 2pt
    cellspacing = 0pt
    ;

  class Pages from Document /
      marginleft = 16
      marginright = 16
      backgroundcolor = colors('bg2')
      pagebreakhtml = html('break')
      tagattr = " onload=""expandAll()"""
      liststyletype = "decimal"
     ;
  end;
run;

ods rtf file="c:\temp\Wealth_trends.rtf" style=BB1;
proc print data=sashelp.shoes(obs=10);
run;
ods rtf close;


use_style_template_sas_94.png
Frequent Contributor
Posts: 129

Re: "Could not locate style reference" error

Thanks Cynthia. All sorted now. I was following an old example (from a SUGI paper I think).

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 1292 views
  • 0 likes
  • 3 in conversation