I want to get a plot like this, with a line at the mean (or geometric mean) and bars for the 95% CI. I'm unsure how to get just the line though.
data _Dummy;
do USUBJID = 1 to 9;
do ARMN= 1 to 5;
do ATPTN= 1, 8, 29, 36, 57, 64, 85, 180, 181, 187, 208, 304;
do PARAMN = 1 to 3; output; end;
output;
end; end; end;
data Dummy;
set _Dummy;
call streaminit(5797);
ATPT = 'Study Day '||strip(ATPTN);
if (ATPTN in (64 85 181) and ARMN = 3)|(ATPTN in (180 187 208 304) and ARMN ^= 3) then delete;
AVAL = rand("integer", 100, 300); /*AVAL=Analysis Value*/
LAVAL = log(AVAL); /*LAVAL=Log Analysis Value*/
run;
proc sgpanel data= Dummy noautolegend;
panelby ATPT / novarname onepanel columns= 3 headerattrs= (family= "times new roman" size= 9) headerbackcolor= "white" sort= data;
scatter x= PARAMN y= AVAL / group= ARMN;
vbox AVAL / group= ARMN category= PARAMN nofill;
rowaxis label= "Worm Numbers";
format PARAMN paramn. ARMN armn.;
run;
data have;
set sashelp.heart(obs=1000);
keep bp_status weight;
run;
proc sort data=have;by bp_status;run;
ods select none;
ods output ConfLimits=ConfLimits ;
proc ttest data=have dist=lognormal;
by bp_status;
var weight;
run;
ods select all;
data want;
set have ConfLimits(keep=bp_status GeomMean LowerCLGeomMean UpperCLGeomMean);
run;
proc sgplot data=want;
scatter x=bp_status y=weight/jitter markerattrs=(symbol=circlefilled size=4) transparency=0.6 group=bp_Status;
scatter x=bp_Status y=GeomMean/yerrorlower=LowerCLGeomMean yerrorupper=UpperCLGeomMean
ERRORBARATTRS=(color=black) ERRORCAPSCALE=4 markerattrs=(size=0);
highlow x=bp_status high=GeomMean low=GeomMean/type=bar lineattrs=(thickness=2) barwidth=0.6;
run;
Please provide the formats paramn and armn.
Your code shows a box plot, but that is not part of your description or the figure you say you want.
Can you clarify, do you want a plot that shows (for each group)
1. jittered points that shows individual values
2. an estimate of central location, such as a mean
3. a confidence interval for the mean
In the picture, there is one class variable per panel. Do you want a panel that shows the ATPT values, and within each panel the groups are determined by the ARMN variable? It looks like the PARMN variable is longitudinal (like different visits) and will be aggregated over?
data have;
set sashelp.heart(obs=1000);
keep bp_status weight;
run;
proc sort data=have;by bp_status;run;
ods select none;
ods output ConfLimits=ConfLimits ;
proc ttest data=have dist=lognormal;
by bp_status;
var weight;
run;
ods select all;
data want;
set have ConfLimits(keep=bp_status GeomMean LowerCLGeomMean UpperCLGeomMean);
run;
proc sgplot data=want;
scatter x=bp_status y=weight/jitter markerattrs=(symbol=circlefilled size=4) transparency=0.6 group=bp_Status;
scatter x=bp_Status y=GeomMean/yerrorlower=LowerCLGeomMean yerrorupper=UpperCLGeomMean
ERRORBARATTRS=(color=black) ERRORCAPSCALE=4 markerattrs=(size=0);
highlow x=bp_status high=GeomMean low=GeomMean/type=bar lineattrs=(thickness=2) barwidth=0.6;
run;
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 16. 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.