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

Hello all,

 

I am using EG 9.4_M6 and am trying to follow the instructions in this SAS blog post to semi-automatically create a discrete attribute map dataset:

https://blogs.sas.com/content/iml/2017/01/30/auto-discrete-attr-map.html

 

I successfully create an attribute map:

Obs ID Value MarkerStyleElement
1 FCIC D001 GraphData1
2 FCIC C001 GraphData2
3 FCIC T001 GraphData3
4 FCIC V001 GraphData4
5 FCIC P001 GraphData5
6 FCIC A001 GraphData6
7 FCIC O001 GraphData7
8 FCIC R001 GraphData8
9 FCIC F001 GraphData9
10 FCIC W001 GraphData10
11 FCIC S001 GraphData11

 

When I try to generate a series plot with the created attribute map, no errors or warnings are reported but it does NOT work correctly; the line colors associated with each MarkerStyleElement (GraphData1 etc) are not associated with the grouping variable (FCIC). The code runs as if I have no attribute map at all.

ods listing gpath='\\Figures' image_DPI=300;
ods graphics / reset height=6.5in imagename="Figure101" imagefmt=PNG;

proc sgplot data=Have noborder
	dattrmap=AttMap;
	where FCIC not in ("A001" "C001" "D001" "F001");

	series x=Year y=Rate /
	Group=FCIC
	Attrid=FCIC;
run;

When I manually add a  "linecolor" column to the attribute map and input specific color names (e.g., yellow, black, etc), the plot is produced as expected with the defined colors. So my attribute map and SGPLOT code appear to be working correctly, just not with the MarkerStyleElement column strategy detailed in the blog post linked at the beginning of this thread.

 

Any ideas why the MarkerStyleElement column in the attribute map dataset is not working as expected?

 

Thanks for reading!

1 ACCEPTED SOLUTION

Accepted Solutions
samp945
Obsidian | Level 7

You pointed me in the right direction! The blog post discusses the MarkerStyleElement column which only specifies marker attributes. My plot does not include markers and that is why the attribute map has no effect. The blog post did not mention that a LineStyleElement column is also available. Therefore, I need to change the code to also create a column called LineStyleElement:

%let VarName = FCIC;           /* specify name of grouping variable */

proc freq data=Series ORDER=FREQ;   /* ORDER=FORMATTED|DATA|FREQ  */
   tables &VarName
		/ out=Attrs(rename=(&VarName=Value));
run;
 
data AttMap;
	ID = "&VarName";                 /* or "ID_&VarName" */
	set Attrs(keep=Value);
		length MarkerStyleElement $11.;
		MarkerStyleElement = cats("GraphData", 1+mod(_N_-1, 12)); /* GraphData1, GraphData2, etc */
		length LineStyleElement $11.;
		LineStyleElement = cats("GraphData", 1+mod(_N_-1, 12)); /* GraphData1, GraphData2, etc */
run;
 
proc print;
run;

 

Now my attribute map contains both MarkerStyleElement and LineStyleElment columns and I can create plots that include both Markers and Lines that are mapped to specific GraphDataN values.

 

My plot now works exactly as expected! Great!

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

Your SERIES plot request does not have markers enabled., so the MarkerStyleElement column has no effect. Add the MARKERS option to the statement and see if that produces what you expect.

samp945
Obsidian | Level 7

You pointed me in the right direction! The blog post discusses the MarkerStyleElement column which only specifies marker attributes. My plot does not include markers and that is why the attribute map has no effect. The blog post did not mention that a LineStyleElement column is also available. Therefore, I need to change the code to also create a column called LineStyleElement:

%let VarName = FCIC;           /* specify name of grouping variable */

proc freq data=Series ORDER=FREQ;   /* ORDER=FORMATTED|DATA|FREQ  */
   tables &VarName
		/ out=Attrs(rename=(&VarName=Value));
run;
 
data AttMap;
	ID = "&VarName";                 /* or "ID_&VarName" */
	set Attrs(keep=Value);
		length MarkerStyleElement $11.;
		MarkerStyleElement = cats("GraphData", 1+mod(_N_-1, 12)); /* GraphData1, GraphData2, etc */
		length LineStyleElement $11.;
		LineStyleElement = cats("GraphData", 1+mod(_N_-1, 12)); /* GraphData1, GraphData2, etc */
run;
 
proc print;
run;

 

Now my attribute map contains both MarkerStyleElement and LineStyleElment columns and I can create plots that include both Markers and Lines that are mapped to specific GraphDataN values.

 

My plot now works exactly as expected! Great!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 448 views
  • 1 like
  • 2 in conversation