Hi Sanjay,
The offsetmin/max = 0.1 worked. Thanks for that.
But I'm still unsure why the problem occured at the first place. So I ran my code without those options. Here is my code and output and attached is the data (sample) in pdf.
%macro labplot(paramcd = , minval = , maxval= , byvar= );
options mprint mlogic;
data adlb;
set adam.adlb;
where saffl = "Y" and aval ne . and paramcd = "%qupcase(¶mcd)";
param = propcase(param);
keep usubjid avisitn avisit paramcd param trtan aval anrlo anrhi;
run;
proc sort data = adlb out=final;
by usubjid;
run;
proc sql noprint;
select param
into: param
from final;
select count(distinct anrlo)
into: n
from final;
select distinct anrlo
into: minref1 - : minref%cmpres(&n.)
from final;
select distinct anrhi
into: maxref1 - : maxref%cmpres(&n.)
from final;
quit;
%let colour = %str(red|green|blue);
ods graphics on / reset=all imagefmt=png outputfmt=PNG border=off height=100% width=100% antialias=on imagename="hemoglobin";
proc sgplot data=final noautolegend;
vbox aval / category=avisitn datalabel=usubjid boxwidth=1;
%do i = 1 %to &n.;
%let col&i = %scan(&colour,&i,'|');
refline &&minref&i &&maxref&i / axis=y lineattrs=(pattern=shortdash color=&&col&i);
%end;
yaxis type=linear values=(&minval. to &maxval. by &byvar.) label=%sysfunc(compbl("¶m."));
xaxis type=linear values=(1 2 3 4 5 6 7) label="Visit" /*offsetmin=0.1 offsetmax=0.1*/;
run;
ods graphics off;
%mend labplot;
%labplot(paramcd = HGB, minval=100, maxval=180, byvar=10);
... View more