Data visualization with SAS programming

How to 'link' changed template and proc sgplot if 'group' option is used

Accepted Solution Solved
Reply
Regular Contributor
Posts: 210
Accepted Solution

How to 'link' changed template and proc sgplot if 'group' option is used

[ Edited ]

Hi all,

 

Could you please help to correct the code:

 

proc sgplot data=F1 noautolegend;

   styleattrs datacontrastcolors=(black)
               datasymbols=(trianglefilled circlefilled squarefilled diamondfilled triangle circle square diamond)
               datalinepatterns=(solid); 

   scatter x=PCTPT y=mean 
							grouporder=data
                            yerrorlower=lower                                                                                            
                            yerrorupper=upper
                            name = "Scatter" ;                                                                               
   series x=PCTPT y=mean /   name = "Series";

   xaxis type = discrete;
   yaxis type = log;

 
run;  

 

 

 


Accepted Solutions
Solution
‎11-03-2017 11:04 AM
SAS Super FREQ
Posts: 1,265

Re: How to 'link' changed template and proc sgplot if 'group' option is used

Both above suggestions will work.  If you just need different attributes per group, and not specific attribute per group "value" (as in IBM should always be blue), an easier way is to use the SGPLOT STYLEATTRS statement.  No need to create a new style or a Discrete Attributes data set.  Please see blog article on this topic.

View solution in original post


All Replies
SAS Super FREQ
Posts: 496

Re: How to 'link' changed template and proc sgplot if 'group' option is used

Posted in reply to DmytroYermak

If you are asking how to make SGPLOT use your new style, then put it on a destination statement.  Example:

ods html style=newblue;

Super User
Posts: 13,066

Re: How to 'link' changed template and proc sgplot if 'group' option is used

Posted in reply to DmytroYermak

Another approach could be the option DATTRMAP which allows you to specify group symbol appearance options based on the values of your group variable without changing any style.

 

DATTRMAP is a data set that would be referenced on the Proc statement and then an attrid option is added to the specific plots to indicate which attribute map value to use with that specific plot.

Your data set would have one line for each value of the group variable, a name to reference and values for the graph items you want to use.

Solution
‎11-03-2017 11:04 AM
SAS Super FREQ
Posts: 1,265

Re: How to 'link' changed template and proc sgplot if 'group' option is used

Both above suggestions will work.  If you just need different attributes per group, and not specific attribute per group "value" (as in IBM should always be blue), an easier way is to use the SGPLOT STYLEATTRS statement.  No need to create a new style or a Discrete Attributes data set.  Please see blog article on this topic.

Regular Contributor
Posts: 210

Re: How to 'link' changed template and proc sgplot if 'group' option is used

[ Edited ]
Posted in reply to Sanjay_SAS

Thank you! It has sorted everything out in one minute.

Regular Contributor
Posts: 210

Re: How to 'link' changed template and proc sgplot if 'group' option is used

Posted in reply to DmytroYermak

Final code (if someone is interested):

proc sgplot data=F1 noautolegend;

   styleattrs datacontrastcolors=(black)
               datasymbols=(trianglefilled circlefilled squarefilled diamondfilled triangle circle square diamond)
               datalinepatterns=(solid); 

   scatter x=PCTPT y=mean / group=TRT01A
							grouporder=data
                            yerrorlower=lower                                                                                            
                            yerrorupper=upper
                            name = "Scatter" ;                                                                               
   series x=PCTPT y=mean /  markers group=TRT01A name = "Series";

   xaxis type = discrete;
   yaxis type = log;

   keylegend "Series"  / location=outside position=topright across=1 noborder;
   format PCTPT $PCTPTF.;
 
run;  
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 218 views
  • 4 likes
  • 4 in conversation