BookmarkSubscribeRSS Feed
Leo9
Quartz | Level 8

I am trying to set the attributes of treatment arm using dattrmap option in proc sgplot but there is no impact.

My group variable is subject and I am using grouplc = treatment. I am trying to control attributes of treatment

but it is not working. Is it because group variable is not treatment ? Is there any way around it ? 

 

data mapt;
length linecolor $10 linepattern $10;
id = "trt" ;
value = "A" ;
linecolor = "blue" ;
linepattern = "mediumdash" ;
output;

id = "trt";
value = "B";
linecolor = "green";
linepattern = "solid" ; 
output;

id = "trt";
value = "C";
linecolor = "red";
linepattern = "mediumdash" ; 
output;

id = "trt";
value = "D";
linecolor = "brown";
linepattern = "solid" ; 
output;
run;

 

proc sgplot data = lbtest dattrmap = mapt noautolegend ;
series x = weeks y = _lbstresn / group = subjid grouplc = treatment attrid = trt name = "ser1" ;
xaxis label = "Study Weeks" values = (&val1 to &val2 by &by);
yaxis label = &lbl values = (&val1 to &val2 by &by );
keylegend "ser1" /type = linecolor location = outside valueattrs = (size=6) title = 'Treatment' ;
run;

 

9 REPLIES 9
JeffMeyers
Barite | Level 11

Try changing your SGPLOT to this.  It looks like your grouplc variable needs to match the attrid variable.  you also can't have multiple / in a statement:

proc sgplot data = lbtest (rename=(treatment=trt)) dattrmap = mapt noautolegend ;
series x = weeks y = _lbstresn / group = subjid grouplc = trt attrid = trt name = "ser1" ;
xaxis label = "Study Weeks" values = (&val1 to &val2 by &by);
yaxis label = &lbl values = (&val1 to &val2 by &by );
keylegend "ser1" /type = linecolor location = outside valueattrs = (size=6) title = 'Treatment' ;
run;
Leo9
Quartz | Level 8

Sorry there was typo in the sample code. The attrid is actually matching. I tried the solution you mentioned but it is not working. 

JeffMeyers
Barite | Level 11

Can you give a PROC FREQ of your TRT (or TREATMENT) variable?  The formatted values have to exactly match those in the attribute map.

Leo9
Quartz | Level 8

I understand it has to match. I made sure it is. I directly copied it from data to avoid any typo but it is not working. 

 

ballardw
Super User

 

 

Use the LCATTRID= to associate the GROUPLC= variable with the attribute map id instead of attrid=

I am not sure the second / in the series statement is a good idea.

Leo9
Quartz | Level 8

Getting error for this  LCATTRID= option. Not sure if it is available. 

ballardw
Super User

@Leo9 wrote:

Getting error for this  LCATTRID= option. Not sure if it is available. 


copy the code and any warnings or errors from the log and paste them into a code box opened using the forums {I} menu icon.

The code box is to maintain text formatting as the message windows here will reformat the diagnostics SAS often supplies with errors.

 

Also which version of SAS are you running?

Leo9
Quartz | Level 8

I am using 9.4M2 I think this option is available from M3 onward. 

JeffMeyers
Barite | Level 11
Can you show what isn't working? Post a picture or error message? I tried your attribute map and sgplot code on my own data and it worked.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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