Data visualization with SAS programming

Yaxis scale

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Yaxis scale

Dear All,

I have 1 more question regarding the following program. I have SAS 9.2 and 9.4.

The error bar is overlapped each other at the same date and obscures group differences. How to move one of the curves either left or right so that the error bars at the same date would not overlap?

Thanks!

data char;
input Date Rate1 RL Rate2 RU;

datalines;

0 . . . .
2 2.5 3.65 2.552 1.482
4 2.444 3.811 2.28 1.118
8 2.60 4.185 2.545 1.039
12 2.385 3.492 2.737 1.316
16 2.454 3.957 2.395 1.182
24 2.524 3.857 2.755 1.515
;

proc sgplot data=char;

xaxis  label='Date'  values=(0 to 24 by 4) ;

yaxis  label="Rate" values=(0.1 1 10 100) min=0.1 max=100 type=log logbase=10 logstyle=logexpand minor ;


series  x=Date y=Rate2 / lineattrs=(pattern=solid color=black thickness=1.5)
                             markers markerattrs =(size=9 color=black symbol=circle)
                             legendlabel='Rate2' name='Sbar';                      
scatter x=Date y=Rate2 / yerrorupper=RU  markerattrs =(size=9 color=black symbol=circle) ;

series  x=Date y=Rate1  / lineattrs=(pattern=dash color=black thickness=1.5) 
                             markers markerattrs =(size=9 color=black symbol=x)
                             legendlabel='Rate1' name='Ebar';                                           
scatter x=Date y=Rate1  / yerrorlower=RL  markerattrs =(size=9 color=black symbol=x) ;     

keylegend "Sbar" "Ebar"/position=topright location=inside across=1;
run;


Accepted Solutions
Solution
‎08-18-2014 04:39 PM
SAS Super FREQ
Posts: 1,077

Re: Yaxis scale

With SAS 9.4, the easiest way would be to change your data to group structure, and use one series and one scatter with groups, with GroupDisplay=Cluster.  You can adjust the Cluster width. Not sure if this is right, but you get the idea.

data charGrp;

  keep date group value low high;

  set char;

  group='Rate1'; value=rate1; low=.; high=ru; output;

  group='Rate2'; value=rate2; low=rl; high=.; output;

  run;

proc sgplot data=charGrp;

xaxis  label='Date'  values=(0 to 24 by 4) ;

yaxis  label="Rate" values=(0.1 1 10 100) min=0.1 max=100 type=log logbase=10 logstyle=logexpand minor ;

series  x=Date y=value / group=group  legendlabel='Rate2' name='Sbar';                      

scatter x=Date y=value / group=group yerrorupper=high yerrorlower=low

        markerattrs =(size=9) groupdisplay=cluster clusterwidth=0.3;

keylegend "Sbar" / position=topright location=inside across=1;

run;

View solution in original post


All Replies
Solution
‎08-18-2014 04:39 PM
SAS Super FREQ
Posts: 1,077

Re: Yaxis scale

With SAS 9.4, the easiest way would be to change your data to group structure, and use one series and one scatter with groups, with GroupDisplay=Cluster.  You can adjust the Cluster width. Not sure if this is right, but you get the idea.

data charGrp;

  keep date group value low high;

  set char;

  group='Rate1'; value=rate1; low=.; high=ru; output;

  group='Rate2'; value=rate2; low=rl; high=.; output;

  run;

proc sgplot data=charGrp;

xaxis  label='Date'  values=(0 to 24 by 4) ;

yaxis  label="Rate" values=(0.1 1 10 100) min=0.1 max=100 type=log logbase=10 logstyle=logexpand minor ;

series  x=Date y=value / group=group  legendlabel='Rate2' name='Sbar';                      

scatter x=Date y=value / group=group yerrorupper=high yerrorlower=low

        markerattrs =(size=9) groupdisplay=cluster clusterwidth=0.3;

keylegend "Sbar" / position=topright location=inside across=1;

run;

Occasional Contributor
Posts: 14

Re: Yaxis scale

thanks Sanjay !!!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 333 views
  • 0 likes
  • 2 in conversation