BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
JacquesR
Quartz | Level 8

Hi all

 

I have tried all kinds of combinations (CXF78874, 'CXF78874'x, etc.) and I cannot seem to hit on the right syntax.

What I want to do is take an attribute map that specifies colours using the SAS Color Naming Scheme (CNS) values with RGB or hexadecimal colour codes.

So what I have is:

 

DATA _AttrMap;
    INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linepattern;
    DATALINES;
    text 0 black 7 bold normal . . 1
    text 1 red 7 normal italic . . 1
    text 2 pink 7 normal italic . . 1
    text 3 purple 7 normal italic . . 1
    text 4 yellow 7 normal italic . . 1
    text 5 blue 7 normal italic . . 1
    text 6 green 7 normal italic . . 1
    line 0 black . . . black black 1
    line 1 red . . . red red 1
	line 2 pink . . . pink pink 1
	line 3 purple . . . purple purple 1
	line 4 yellow . . . yellow yellow 1
	line 5 blue . . . blue blue 1
	line 6 green . . . green green 1
    ;
RUN;

I have used an arbitrary (and probably garish) sequence of simple CNS colour names above, so I am not out to replace colour for colour, but rather, assuming I have a bunch of RGB or Hex codes for colours that I do want to use, and I have no idea what their CNS names are, I want to use those colours in my attribute map.

 

 

So what I would want would, I would have thought, looked something like this:

 

DATA _AttrMap;
    INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linestyle;
    DATALINES;
    text 0 CXRRGGBB 7 bold normal . . 1
    text 1 CXF78874 7 normal italic . . 1
    text 2 CXF98682 7 normal italic . . 1
    text 3 CXF88592 7 normal italic . . 1
    text 4 CXF387A1 7 normal italic . . 1
    text 5 CXEA8BB0 7 normal italic . . 1
    text 6 CXDE90BD 7 normal italic . . 1
    line 0 CXRRGGBB . . . CXRRGGBB CXRRGGBB 1
    line 1 CXF78874 . . . CXF78874 CXF78874 1
	line 2 CXF98682 . . . CXF98682 CXF98682 1
	line 3 CXF88592 . . . CXF88592 CXF88592 1
	line 4 CXF387A1 . . . CXF387A1 CXF387A1 1
	line 5 CXEA8BB0 . . . CXEA8BB0 CXEA8BB0 1
	line 6 CXDE90BD . . . CXDE90BD CXDE90BD 1
    ;
RUN;

According to these pages, I would have thought it would work:

 

https://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#colors-specify-c... 

https://support.sas.com/documentation/cdl/en/graphref/65389/HTML/default/viewer.htm#p0ekhb3mdqahk3n1... 

https://blogs.sas.com/content/iml/2012/10/22/whats-in-a-name.html 

 

But I get this error (truncated below):

 

WARNING: Invalid color CXDE90BD specified. The color will be mapped to gray.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS, MARKERATTRS, TEXTATTRS.

That, b.t.w., is when I use:

PROC SGPLOT
    DATTRMAP=_AttrMap1
    DATA=mydata;

I know it's not the colour values themselves, because this, for example, works, but defeats the purpose of using an attribute map to simplify the creation of numerous charts using a consistent colour scheme:

PROC SGPLOT
    DATA=mydata;
STYLEATTRS 
   DATACONTRASTCOLORS=(CXF78874 CXDE90BD CX7CAFD7 CX3FBDA5 CX92B85B CXE39F4F) 
DATACOLORS=(CXF78874 CXDE90BD CX7CAFD7 CX3FBDA5 CX92B85B CXE39F4F) 
DATALINEPATTERNS=(1);

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I reduced your dattmap set just to pick one color to demonstrate the color name worked.

 

You might look at using this version as well:

data junk;
   input x y grp text $;
datalines;
1 1 1  abc
2 2 2  def
3 3 3  ghi
4 4 4  lmn
5 5 5  0pq
6 6 6  rst
0 0 0  zzz

;

proc sgplot data=junk dattrmap=_attrmap;
  text x=x y=y text=text /group=grp attrid=text;
run;

And see if you get different colors.

Some of the TEXT variables in my online help indicate that they only affect AXIS Table elements.

 

The error appears to be caused by the use of LINESTYLE which expects to see the name of a graphstyle element.

I think you might try changing to LINEPATTERN instead and see if that corrects the errors.

 

View solution in original post

12 REPLIES 12
Ksharp
Super User

Here could give you a hand.

filename _colors TEMP;    /* create a temporary text file */
 
/* write text file with colors from the registry */
proc registry startat='HKEY_SYSTEM_ROOT\COLORNAMES' list export=_colors;
run; 





  data RegistryRGB;
   infile _colors end=eof;         /* read from text file; last line sets EOF flag to true */
   input;                          /* read one line at a time into _infile_ */
 
   length ColorName $32 hex $8; 
   retain hex "CX000000";
   s = _infile_;
   k = findw(s, 'hex:');          /* does the string 'hex' appear? */
   if k then do;                  /* this line contains a color */
      i = findc(s, '=', 2);       /* find the second quotation mark (") */
      ColorName = substr(s, 2, i-3);            /* name is between the quotes */
      /* build up the hex value from a comma-delimited value like 'FA,EB,D7' */
      substr(hex, 3, 2) = substr(s, k+5 , 2);
      substr(hex, 5, 2) = substr(s, k+8 , 2);
      substr(hex, 7, 2) = substr(s, k+11, 2);
 
      R = inputn(substr(hex, 3, 2), "HEX2."); /* get RGB coordinates from hex */
      G = inputn(substr(hex, 5, 2), "HEX2.");
      B = inputn(substr(hex, 7, 2), "HEX2.");
   end;
   if k;
   drop k i s;
run;






/*ods pdf file='D:\XiaKeShan\All_COLOR.pdf';*/
options nodate ;
title;
proc report data=work.RegistryRGB nowd;
  column  colorname hex R G B; 
  define colorname/ 'Color Name';
  compute b; 
     call   define(_row_,'style','style={background='||colorname||'}');
  endcomp;
  run;
/*ods pdf close;*/

Ksharp_0-1702276608510.png

 

JacquesR
Quartz | Level 8

Thank you, that looks useful, but on my system, I am only getting 151 colours, and lists like this are actually available on the web. It does not, for example, contain the list of colours I want to use.

In the end, I was asking how to use the RGB codes in the attribute map, not how to find CNS equivalents for them.

JosvanderVelden
SAS Super FREQ

I've run the code you provided on SAS OnDemand for Academics and do not encounter the error.

DATA _AttrMap;
INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linestyle;
DATALINES;
text 0 CXRRGGBB 7 bold normal . . 1
text 1 CXF78874 7 normal italic . . 1
text 2 CXF98682 7 normal italic . . 1
text 3 CXF88592 7 normal italic . . 1
text 4 CXF387A1 7 normal italic . . 1
text 5 CXEA8BB0 7 normal italic . . 1
text 6 CXDE90BD 7 normal italic . . 1
line 0 CXRRGGBB . . . CXRRGGBB CXRRGGBB 1
line 1 CXF78874 . . . CXF78874 CXF78874 1
line 2 CXF98682 . . . CXF98682 CXF98682 1
line 3 CXF88592 . . . CXF88592 CXF88592 1
line 4 CXF387A1 . . . CXF387A1 CXF387A1 1
line 5 CXEA8BB0 . . . CXEA8BB0 CXEA8BB0 1
line 6 CXDE90BD . . . CXDE90BD CXDE90BD 1
;
RUN;
DATA _AttrMap;
INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linestyle;
DATALINES;
text 0 CXRRGGBB 7 bold normal . . 1
text 1 CXF78874 7 normal italic . . 1
text 2 CXF98682 7 normal italic . . 1
text 3 CXF88592 7 normal italic . . 1
text 4 CXF387A1 7 normal italic . . 1
text 5 CXEA8BB0 7 normal italic . . 1
text 6 CXDE90BD 7 normal italic . . 1
line 0 CXRRGGBB . . . CXRRGGBB CXRRGGBB 1
line 1 CXF78874 . . . CXF78874 CXF78874 1
line 2 CXF98682 . . . CXF98682 CXF98682 1
line 3 CXF88592 . . . CXF88592 CXF88592 1
line 4 CXF387A1 . . . CXF387A1 CXF387A1 1
line 5 CXEA8BB0 . . . CXEA8BB0 CXEA8BB0 1
line 6 CXDE90BD . . . CXDE90BD CXDE90BD 1
;
RUN;
Do you get the error when you run this code? If not when does the error occur. Please send log with code, warnings and errors
JacquesR
Quartz | Level 8

Hi Jos

As I said in my original post, the error is generated when I run an SGPLOT step.

So, for example, here is some data:


  data ORs;
  INPUT YLabel $ Level	E	L	U	IndentWt	GrpText	GrpLine	Ref	_N;
  DATALINES;
Death	1	.	.	.	0	0	0	1	1
Intervention	2	0.55913	0.47636	0.6563	1	1	1	.	2
Days	2	2.80867	2.56724	3.0728	1	2	2	.	3
Sex	2	0.76004	0.64817	0.8912	1	3	3	.	4
Age	2	6.26008	3.89077	10.0722	1	4	4	.	5
Ward	2	1.67351	1.33596	2.0963	1	5	5	.	6
ED	2	4.11632	3.2314	5.2436	1	6	6	.	7
Lactate	1	.	.	.	0	0	0	8	8
Intervention	2	0.87583	0.70427	1.0892	1	1	1	.	9
Days	2	3.31815	2.99353	3.678	1	2	2	.	10
Sex	2	0.41019	0.33098	0.5084	1	3	3	.	11
Age	2	0.66652	0.51794	0.8577	1	4	4	.	12
Ward	2	0.44343	0.35548	0.5532	1	5	5	.	13
ED	2	1.23311	0.98223	1.5481	1	6	6	.	14
BP	1	.	.	.	0	0	0	15	15
Intervention	2	0.69487	0.62944	0.7671	1	1	1	.	16
Days	2	2.49906	2.37615	2.6283	1	2	2	.	17
Sex	2	0.7858	0.71351	0.8654	1	3	3	.	18
Age	2	1.14297	1.00717	1.2971	1	4	4	.	19
Ward	2	0.59325	0.53268	0.6607	1	5	5	.	20
ED	2	1.2314	1.10566	1.3714	1	6	6	.	21
eGFR	1	.	.	.	0	0	0	22	22
Intervention	2	0.82326	0.76245	0.8889	1	1	1	.	23
Days	2	3.0386	2.91297	3.1697	1	2	2	.	24
Sex	2	0.98662	0.91651	1.0621	1	3	3	.	25
Age	2	4.25326	3.68021	4.9155	1	4	4	.	26
Ward	2	0.80556	0.73838	0.8789	1	5	5	.	27
ED	2	2.3231	2.13229	2.531	1	6	6	.	28
;
RUN;

And here is the plot:

PROC SGPLOT
    NOAUTOLEGEND
    NOBORDER
    NOCYCLEATTRS
    NOWALL
    DATTRMAP=_AttrMap
    DATA=ORs;
	/* It works to use GB hex values in STYLEATTRS */
	/*	STYLEATTRS DATACONTRASTCOLORS=(CXF78874 CXDE90BD CX7CAFD7 CX3FBDA5 CX92B85B CXE39F4F) DATALINEPATTERNS=(1);*/
	XAXIS DISPLAY=(NOLABEL)
          LABELATTRS=(SIZE=8)
	      VALUES=(0.25 0.5 1 to 12 by 1)
	      VALUEATTRS=(SIZE=6)
	      TYPE=Log;
    YAXIS REVERSE
          TYPE=DISCRETE
          DISPLAY=NONE
          OFFSETMIN=0.01;
    YAXISTABLE YLabel
               /LOCATION=INSIDE
                POSITION=LEFT
                TEXTGROUP=GrpText
                TEXTGROUPID=text
				NOLABEL
                INDENTWEIGHT=IndentWt
                SEPARATOR;
    REFLINE 1 /AXIS=X LINEATTRS=(COLOR=BLACK);
    REFLINE Ref /AXIS=Y LINEATTRS=(COLOR=LIGHTBLUE) TRANSPARENCY=0.8 DISCRETETHICKNESS=0.8;
    SCATTER Y=_N
            X=E
            /MARKERATTRS=(SIZE=6 SYMBOL=SQUARE)
             ATTRID=line
             GROUP=GrpLine;
    HIGHLOW Y=_N
            LOW=L
            HIGH=U
            /ATTRID=line
             GROUP=GrpLine;
    TITLE;
RUN;
ballardw
Super User

Of possible use to you, SAS has a utility macro, %colormac that will make a number of macros available to convert from one color system to another.

In your program you would include:

%colormac;

which compiles a number of macros.

Then you may want to consider the %cns macro which will create HLS colors.

 

If you want RGB nest function calls:

%colormac;
data example;
hls = "%cns(purple)";
rgb = "%hls2rgb(%cns(purple))";
run;
 

 

JacquesR
Quartz | Level 8

Thanks for that, but you will notice that the first hyperlink I provided was

https://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#colors-specify-c... 

Which is the web page that lists those macros, and yes, I had looked at them, but there is no macro to convert RGB to CNS.

Even if there were, that was not my question, as I pointed out in my previous reply.

My question is this:

I can create an attribute map, but when I use it in an SGPLOT step, it generates an error. It seems as if attribute maps either can only contain CNS colour names when used in plot statements, or the RGB (or HLS) colours need to specified in some way that I cannot figure out. I have not been able to find any documentation explicitly stating that attribute maps must use CNS colour names, but all the examples I could find only use CNS colour names.

ballardw
Super User

Your subject line is "replacing SAS Color Naming Scheme (CNS) color names" not "replacing RGB" so I am not at all sure why you said ", but there is no macro to convert RGB to CNS.".

 

Also, you have shown an attribute data set. No data. No code to plot the data. And  no log with any errors that we can see why you thing that other color naming systems don't work.

 

If CXRRGGBB is supposed to be RGB then you need to pay attention to the numeric limits. FF is the largest hex value (256) acceptable in RGB so RR and GG are right out.

 

A reduced example showing RGB codes in the correct ranges do work.

 

DATA _AttrMap;
    INPUT ID $ Value TextColor $;
DATALINES;
text 0 CX154565
text 1 CXF78874
text 2 CXF98682
text 3 CXF88592
text 4 CXF387A1
text 5 CXEA8BB0
text 6 CXDE90BD
;
RUN;

data junk;
   input x y grp text $;
datalines;
1 1 1  abc
2 2 2  def
3 3 3  ghi
4 4 4  lmn
5 5 5  0pq
6 6 6  rst
0 0 0  zzz

;

proc sgplot data=junk dattrmap=_attrmap;
  text x=x y=y text=text /group=grp attrid=text;
run;

 


@JacquesR wrote:

Thanks for that, but you will notice that the first hyperlink I provided was

https://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#colors-specify-c... 

Which is the web page that lists those macros, and yes, I had looked at them, but there is no macro to convert RGB to CNS.

Even if there were, that was not my question, as I pointed out in my previous reply.

My question is this:

I can create an attribute map, but when I use it in an SGPLOT step, it generates an error. It seems as if attribute maps either can only contain CNS colour names when used in plot statements, or the RGB (or HLS) colours need to specified in some way that I cannot figure out. I have not been able to find any documentation explicitly stating that attribute maps must use CNS colour names, but all the examples I could find only use CNS colour names.


 

 

JacquesR
Quartz | Level 8

Hi @ballardw 

 

I have been struggling to express what I want.

So ignore the Subject of the  thread (in fact, I will rename it to be less confusing).

Also, thanks for spotting the CXRRGGBB mistake, that was, of course, a column header that got copied in. The first row, of course, should be CX000000.

 

So let me try to state the problem all over again.

I have multiple plots for which I want to use an attribute map, this one is an example:


  DATA ORs;
  INPUT YLabel $ Level	E	L	U	IndentWt	GrpText	GrpLine	Ref	_N;
  DATALINES;
Death	1	.	.	.	0	0	0	1	1
Intervention	2	0.55913	0.47636	0.6563	1	1	1	.	2
Days	2	2.80867	2.56724	3.0728	1	2	2	.	3
Sex	2	0.76004	0.64817	0.8912	1	3	3	.	4
Age	2	6.26008	3.89077	10.0722	1	4	4	.	5
Ward	2	1.67351	1.33596	2.0963	1	5	5	.	6
ED	2	4.11632	3.2314	5.2436	1	6	6	.	7
Lactate	1	.	.	.	0	0	0	8	8
Intervention	2	0.87583	0.70427	1.0892	1	1	1	.	9
Days	2	3.31815	2.99353	3.678	1	2	2	.	10
Sex	2	0.41019	0.33098	0.5084	1	3	3	.	11
Age	2	0.66652	0.51794	0.8577	1	4	4	.	12
Ward	2	0.44343	0.35548	0.5532	1	5	5	.	13
ED	2	1.23311	0.98223	1.5481	1	6	6	.	14
BP	1	.	.	.	0	0	0	15	15
Intervention	2	0.69487	0.62944	0.7671	1	1	1	.	16
Days	2	2.49906	2.37615	2.6283	1	2	2	.	17
Sex	2	0.7858	0.71351	0.8654	1	3	3	.	18
Age	2	1.14297	1.00717	1.2971	1	4	4	.	19
Ward	2	0.59325	0.53268	0.6607	1	5	5	.	20
ED	2	1.2314	1.10566	1.3714	1	6	6	.	21
eGFR	1	.	.	.	0	0	0	22	22
Intervention	2	0.82326	0.76245	0.8889	1	1	1	.	23
Days	2	3.0386	2.91297	3.1697	1	2	2	.	24
Sex	2	0.98662	0.91651	1.0621	1	3	3	.	25
Age	2	4.25326	3.68021	4.9155	1	4	4	.	26
Ward	2	0.80556	0.73838	0.8789	1	5	5	.	27
ED	2	2.3231	2.13229	2.531	1	6	6	.	28
;
RUN;

PROC SGPLOT
    NOAUTOLEGEND
    NOBORDER
    NOCYCLEATTRS
    NOWALL
    DATTRMAP=_AttrMap
    DATA=ORs;
	/* It works to use GB hex values in STYLEATTRS */
	/*	STYLEATTRS DATACONTRASTCOLORS=(CXF78874 CXDE90BD CX7CAFD7 CX3FBDA5 CX92B85B CXE39F4F) DATALINEPATTERNS=(1);*/
	XAXIS DISPLAY=(NOLABEL)
          LABELATTRS=(SIZE=8)
	      VALUES=(0.25 0.5 1 to 12 by 1)
	      VALUEATTRS=(SIZE=6)
	      TYPE=Log;
    YAXIS REVERSE
          TYPE=DISCRETE
          DISPLAY=NONE
          OFFSETMIN=0.01;
    YAXISTABLE YLabel
               /LOCATION=INSIDE
                POSITION=LEFT
                TEXTGROUP=GrpText
                TEXTGROUPID=text
				NOLABEL
                INDENTWEIGHT=IndentWt
                SEPARATOR;
    REFLINE 1 /AXIS=X LINEATTRS=(COLOR=BLACK);
    REFLINE Ref /AXIS=Y LINEATTRS=(COLOR=LIGHTBLUE) TRANSPARENCY=0.8 DISCRETETHICKNESS=0.8;
    SCATTER Y=_N
            X=E
            /MARKERATTRS=(SIZE=6 SYMBOL=SQUARE)
             ATTRID=line
             GROUP=GrpLine;
    HIGHLOW Y=_N
            LOW=L
            HIGH=U
            /ATTRID=line
             GROUP=GrpLine;
    TITLE;
RUN;

If I define the colours using the STYLEATTRS statement (commented out above), then it works, but this defeats the purpose of using an attribute map to simplify the creation of numerous charts using a consistent colour scheme.

If I create an attribute map using CNS colour names, the SGPLOT statement works:

DATA _AttrMap;
    INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linepattern;
    DATALINES;
    text 0 black 7 bold normal . . 1
    text 1 red 7 normal italic . . 1
    text 2 pink 7 normal italic . . 1
    text 3 purple 7 normal italic . . 1
    text 4 yellow 7 normal italic . . 1
    text 5 blue 7 normal italic . . 1
    text 6 green 7 normal italic . . 1
    line 0 black . . . black black 1
    line 1 red . . . red red 1
	line 2 pink . . . pink pink 1
	line 3 purple . . . purple purple 1
	line 4 yellow . . . yellow yellow 1
	line 5 blue . . . blue blue 1
	line 6 green . . . green green 1
    ;
RUN;

However, if I recreate the attribute map using RGB colours (this time using arbitrary colour codes from the list created by @Ksharp , just to ensure that I have only valid codes):

DATA _AttrMap;
    INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linestyle;
    DATALINES;
    text 0 CX000000 7 bold normal . . 1
    text 1 CX0000FF 7 normal italic . . 1
    text 2 CXD2691E 7 normal italic . . 1
    text 3 CX7FFF00 7 normal italic . . 1
    text 4 CX5F9EA0 7 normal italic . . 1
    text 5 CXDC143C 7 normal italic . . 1
    text 6 CX00FFFF 7 normal italic . . 1
    line 0 CX000000 . . . CX000000 CX000000 1
    line 1 CX0000FF . . . CX0000FF CX0000FF 1
	line 2 CXD2691E . . . CXD2691E CXD2691E 1
	line 3 CX7FFF00 . . . CX7FFF00 CX7FFF00 1
	line 4 CX5F9EA0 . . . CX5F9EA0 CX5F9EA0 1
	line 5 CXDC143C . . . CXDC143C CXDC143C 1
	line 6 CX00FFFF . . . CX00FFFF CX00FFFF 1
    ;
RUN;

 

Then the full log is just a repetition of what I copied in the original post, but to satisfy everyone's curiosity:

ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, FILLATTRS, LINEATTRS,
              MARKERATTRS, TEXTATTRS.
ERROR 200-322: The symbol is not recognized and will be ignored.
WARNING: Object will not be saved.
NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 14 observations read from the data set WORK._ATTRMAP.

@ballardw I find it interesting that your example works, but the plot is slightly different, it uses textcolor, whereas I am using textcolor. linecolor and fillcolor.

Why does my example attribute map work when those three are defined with CNS names, but not with RGB codes?

ballardw
Super User

I reduced your dattmap set just to pick one color to demonstrate the color name worked.

 

You might look at using this version as well:

data junk;
   input x y grp text $;
datalines;
1 1 1  abc
2 2 2  def
3 3 3  ghi
4 4 4  lmn
5 5 5  0pq
6 6 6  rst
0 0 0  zzz

;

proc sgplot data=junk dattrmap=_attrmap;
  text x=x y=y text=text /group=grp attrid=text;
run;

And see if you get different colors.

Some of the TEXT variables in my online help indicate that they only affect AXIS Table elements.

 

The error appears to be caused by the use of LINESTYLE which expects to see the name of a graphstyle element.

I think you might try changing to LINEPATTERN instead and see if that corrects the errors.

 

whymath
Lapis Lazuli | Level 10

Just change linestyle to linepattern then the problem solved.

DATA _AttrMap;
    INPUT ID $ Value TextColor $ TextSize TextWeight $ TextStyle $ linecolor $ fillcolor $ linepattern;
    DATALINES;
    text 0 CX000000 7 bold normal . . 1
    text 1 CX0000FF 7 normal italic . . 1
    text 2 CXD2691E 7 normal italic . . 1
    text 3 CX7FFF00 7 normal italic . . 1
    text 4 CX5F9EA0 7 normal italic . . 1
    text 5 CXDC143C 7 normal italic . . 1
    text 6 CX00FFFF 7 normal italic . . 1
    line 0 CX000000 . . . CX000000 CX000000 1
    line 1 CX0000FF . . . CX0000FF CX0000FF 1
	line 2 CXD2691E . . . CXD2691E CXD2691E 1
	line 3 CX7FFF00 . . . CX7FFF00 CX7FFF00 1
	line 4 CX5F9EA0 . . . CX5F9EA0 CX5F9EA0 1
	line 5 CXDC143C . . . CXDC143C CXDC143C 1
	line 6 CX00FFFF . . . CX00FFFF CX00FFFF 1
    ;
RUN;

Note the last variable of this data step.

JacquesR
Quartz | Level 8

Why, though, does linestyle work with the CNS names, and not with the RGB values?

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 12 replies
  • 3427 views
  • 3 likes
  • 5 in conversation