I need to add follwoing:
X axis visit
Y axis change
boxplot with each subjid overlay with different symbol and color
I also need to separate shaded area for first 4 visits as treated verus rest of the visits as non treated.
data adprop;
call streaminit(123);
do i=1 to 8;
do avisitn=1 to 8;
if avisitn in (1:4) then group='treat ';
else group='nontreat';
chg=rand('uniform');
output;
end;
end;
run;
data dattrmap;
id='id';
input value MarkerSymbol : $20. MarkerColor :$20.;
cards;
1 StarFilled Bisque
2 Asterisk Aqua
3 Circle Black
4 Triangle Blue
5 Diamond red
6 TriangleFilled green
7 DiamondFilled yellow
8 Hash Brown
9 Plus Chartreuse
10 X Coral
11 Square DeepPink
12 Y Fuchsia
13 Z Tomato
15 Star YellowGreen
;
proc sgplot data= adprop dattrmap=dattrmap;
vbox chg/ category= avisitn ; *group=avisitn;
scatter x=avisitn y=chg/jitter group=avisitn attrid=id;
block x=avisitn block=group / filltype=alternate fillattrs=(color=grey transparency=0.8)
altfillattrs=(color=white transparency=1) ;
run;
Maybe we have a different idea of what a boxplot does, but if you have X as visit and Y as change, I guess its not obvious to me where the variable subject fits in. Could you show us an example of such a boxplot?
How can i create different symbol and color of the jitter for each subjectid (small circles on box plots)?
In the VBOX statement you can label the outliers with the value of a variable (like an ID) by using the DATALABEL= option. I don't think you can have the outlier markers have a different color depending on the ID.
data adprop;
call streaminit(123);
do i=1 to 8;
do avisitn=1 to 8;
if avisitn in (1:4) then group='treat ';
else group='nontreat';
chg=rand('uniform');
output;
end;
end;
run;
data dattrmap;
id='id';
input value MarkerSymbol : $20. MarkerColor :$20.;
cards;
1 StarFilled Bisque
2 Asterisk Aqua
3 Circle Black
4 Triangle Blue
5 Diamond red
6 TriangleFilled green
7 DiamondFilled yellow
8 Hash Brown
9 Plus Chartreuse
10 X Coral
11 Square DeepPink
12 Y Fuchsia
13 Z Tomato
15 Star YellowGreen
;
proc sgplot data= adprop dattrmap=dattrmap;
vbox chg/ category= avisitn ; *group=avisitn;
scatter x=avisitn y=chg/jitter group=avisitn attrid=id;
block x=avisitn block=group / filltype=alternate fillattrs=(color=grey transparency=0.8)
altfillattrs=(color=white transparency=1) ;
run;
To get the values spaced as you described, trying setting TYPE=LINEAR on the XAXIS statement and see if you the desired results. By default, the category axis type for box plots is DISCRETE.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.