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;
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;
Sorry there was typo in the sample code. The attrid is actually matching. I tried the solution you mentioned but it is not working.
Can you give a PROC FREQ of your TRT (or TREATMENT) variable? The formatted values have to exactly match those in the attribute map.
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.
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.
Getting error for this LCATTRID= option. Not sure if it is available.
@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?
I am using 9.4M2 I think this option is available from M3 onward.
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!
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.