BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Doug____
Pyrite | Level 9

Attribute map has no effect using the following code - plot produces ok but not with the symbols and colors I want. Only tenure categories 2 - 7 are in the dataset - category 1 is eliminated prior to the where clause.

 

data myattrmap;
id='scattersymbols';
length markersymbol $20;
input value $ markercolor $ markersymbol $;
datalines;
2 red circlefilled
3 blue squarefilled
4 yellow trianglefilled
5 green circlefilled
6 orange squarefilled
7 black trianglefilled
;
run;

 

proc sgplot data = rank_ratiox dattrmap = myattrmap;
where portfolio>=10000 and cat = "CAG" and title_group = "FA";
scatter x = portfolio y = kpi_annual / group = tenure2 grouporder = ascending attrid = scattersymbols ;
xaxis label = "Portfolio (000s)" grid values = (0 to 1000000 by 100000) valueattrs = (family = calibri size = 7pt) labelattrs = (family = calibri size = 7pt);
yaxis label = "Annual Contrib" grid values = (0 to 7000000 by 1000000) valueattrs = (family = calibri size = 7pt) labelattrs = (family = calibri size = 7pt);
keylegend /title = 'Tenure (Years)' valueattrs = (family = calibri size = 7pt) titleattrs = (family = calibri size = 7pt);
format tenure2 tenureC. portfolio kpi_annual comma12.;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

It looks to me like the attribute map is set up correctly. It will work when the (formatted) values of tenure2 are 2-7, as shown below:

data myattrmap;
id='scattersymbols';
length markersymbol $20;
input value $ markercolor $ markersymbol $;
datalines;
2 red circlefilled
3 blue squarefilled
4 yellow trianglefilled
5 green circlefilled
6 orange squarefilled
7 black trianglefilled
;

proc print data=myattrmap; run;

data A;
call streaminit(1);
do tenure2 = 2 to 7;
   i = mod(tenure2, 3);
   j = int(tenure2 /3);
   do k = 1 to 20;
      x = i + rand("Normal",0,0.3);
      y = j + rand("Normal",0,0.3);
      output;
   end;
end;
run;

proc sgplot data=A dattrmap = myattrmap;
scatter x = x y = y / group = tenure2 grouporder = ascending attrid = scattersymbols ;
keylegend /title = 'Tenure (Years)' valueattrs = (family = calibri size = 7pt) titleattrs = (family = calibri size = 7pt);
run;

Remove TENURE2 from the FORMAT statement or use formatted values when you create the myattrmap data set.

View solution in original post

2 REPLIES 2
ballardw
Super User

Since you are using Tenure2 as your group variable then the values that appear in the dattrmap data set have to match those in the format in effect for the variable at the time of use. Since your Tenure2 is using TenureC. format for the SGPLOT then the values need to match those of the TenureC format.

 

So, what is the definition of TenureC?

Rick_SAS
SAS Super FREQ

It looks to me like the attribute map is set up correctly. It will work when the (formatted) values of tenure2 are 2-7, as shown below:

data myattrmap;
id='scattersymbols';
length markersymbol $20;
input value $ markercolor $ markersymbol $;
datalines;
2 red circlefilled
3 blue squarefilled
4 yellow trianglefilled
5 green circlefilled
6 orange squarefilled
7 black trianglefilled
;

proc print data=myattrmap; run;

data A;
call streaminit(1);
do tenure2 = 2 to 7;
   i = mod(tenure2, 3);
   j = int(tenure2 /3);
   do k = 1 to 20;
      x = i + rand("Normal",0,0.3);
      y = j + rand("Normal",0,0.3);
      output;
   end;
end;
run;

proc sgplot data=A dattrmap = myattrmap;
scatter x = x y = y / group = tenure2 grouporder = ascending attrid = scattersymbols ;
keylegend /title = 'Tenure (Years)' valueattrs = (family = calibri size = 7pt) titleattrs = (family = calibri size = 7pt);
run;

Remove TENURE2 from the FORMAT statement or use formatted values when you create the myattrmap data set.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 2 replies
  • 1675 views
  • 0 likes
  • 3 in conversation