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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1001 views
  • 0 likes
  • 3 in conversation