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;
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.
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?
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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: