Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dsam
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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;

Ksharp_0-1742022607128.png

 

View solution in original post

8 REPLIES 8
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
dsam
Fluorite | Level 6

dsam_0-1741963412930.png

How can i create different symbol and color of the jitter for each subjectid  (small circles on box plots)?

dsam
Fluorite | Level 6
this is my code:
proc sgplot data= adprop;
vbox chg/ category= avisitn;
scatter x=avisitn y=chg/jitter ;
run;
PaigeMiller
Diamond | Level 26

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. 

--
Paige Miller
Ksharp
Super User
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;

Ksharp_0-1742022607128.png

 

dsam
Fluorite | Level 6
This works, the only problem now is I have visits 0, 2, 4, 6, 8, 10, 12, and then 16, 20, 24. this groups shaded area in the middle where 14. but I want to cut the shadded area at 12. also, I want to have distance spread out accordingly like distance from 12 to 14 should be more compared to 10 to 12.
DanH_sas
SAS Super FREQ

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1268 views
  • 1 like
  • 4 in conversation