<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Plotting Logaxis values when the value is zero in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66069#M2255</link>
    <description>I would copy the X variable to an X2 column and replace all of the zeros with missing values. Then, use that column for your log axis. Let me know if that helps.&lt;BR /&gt;
&lt;BR /&gt;
Dan</description>
    <pubDate>Tue, 09 Mar 2010 16:40:03 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2010-03-09T16:40:03Z</dc:date>
    <item>
      <title>Plotting Logaxis values when the value is zero</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66068#M2254</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am using GTL and SGRENDER to plot the linear and Logarithmic graphs on the same page. Since, I am having zero values Logarithmic axis can not be plotted. I can see the note from the log NOTE: Log axis cannot support zero or negative values in the data range.&lt;BR /&gt;
The axis type will be changed to LINEAR.&lt;BR /&gt;
Since I need these values for plotting linear values I can not delete these values from the dataset. Is there anyway we could force&lt;BR /&gt;
to use log scale or subset the data in the GTL code for the log plot? Please see the test code below.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
   proc template;&lt;BR /&gt;
   define statgraph sgplot7;&lt;BR /&gt;
      dynamic __BYLINE__ _ticklist_ timevar yvar trtvar sidvar  &lt;BR /&gt;
              _title0 _title1 _title2 _title3 &lt;BR /&gt;
              _title4 _title5 _title6 _title7 _title8 _title9 _title10&lt;BR /&gt;
              _footnote1 _footnote2 _footnote3 _footnote4 _footnote5&lt;BR /&gt;
              _footnote6 _footnote7 _footnote8 _footnote9 _footnote10;&lt;BR /&gt;
		 		 		   nmvar _xoffset_min _xoffset_max _xmin _xmax _xorder &lt;BR /&gt;
                    _yoffset_min _yoffset_max _ymin _ymax;&lt;BR /&gt;
      &lt;BR /&gt;
      begingraph;&lt;BR /&gt;
         layout lattice  /columns=2;&lt;BR /&gt;
        &lt;BR /&gt;
         layout overlay / xaxisopts=( &lt;BR /&gt;
                                type=linear offsetmin=_xoffset_min offsetmax=_xoffset_max &lt;BR /&gt;
                                linearopts=( /* tickvaluelist=(&amp;amp;_xorder) */&lt;BR /&gt;
                                viewmin=_xmin &lt;BR /&gt;
                                viewmax=_xmax )) &lt;BR /&gt;
                    yaxisopts=( &lt;BR /&gt;
                                type=linear offsetmin=_yoffset_min offsetmax=_yoffset_max &lt;BR /&gt;
		 		 		 		 		 		 		 		 linearopts=( viewmin=_ymin viewmax=_ymax )&lt;BR /&gt;
                                );&lt;BR /&gt;
         ScatterPlot X=timevar Y=yvar / markerattrs=(color=black)&lt;BR /&gt;
                                        LegendLabel="mean" &lt;BR /&gt;
                                        NAME="scat";&lt;BR /&gt;
        endlayout;&lt;BR /&gt;
		 		 cell; &lt;BR /&gt;
            cellheader;&lt;BR /&gt;
		             entry "Semi-log" / textattrs=GraphLabelText;&lt;BR /&gt;
		         endcellheader;&lt;BR /&gt;
   &lt;BR /&gt;
   layout overlay / xaxisopts=( &lt;BR /&gt;
                                type=linear offsetmin=_xoffset_min offsetmax=_xoffset_max &lt;BR /&gt;
                                linearopts=( /* tickvaluelist=(&amp;amp;_xorder) */&lt;BR /&gt;
                                viewmin=_xmin &lt;BR /&gt;
                                viewmax=_xmax ))&lt;BR /&gt;
		 		 		 		 		 yaxisopts=( &lt;BR /&gt;
                                type=log offsetmin=_yoffset_min offsetmax=_yoffset_max &lt;BR /&gt;
		 		 		 		 		 		 		 		 logopts=( Base=10 ));&lt;BR /&gt;
  &lt;BR /&gt;
   ScatterPlot X=timevar Y=yvar / markerattrs=(color=black)&lt;BR /&gt;
                                  LegendLabel="mean" NAME="scat";&lt;BR /&gt;
&lt;BR /&gt;
   endlayout;&lt;BR /&gt;
   endcell;&lt;BR /&gt;
endlayout;&lt;BR /&gt;
&lt;BR /&gt;
endgraph;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
   title;&lt;BR /&gt;
   footnote;&lt;BR /&gt;
&lt;BR /&gt;
   %let _xvar=visit;&lt;BR /&gt;
   %let _yvar=m_wtgain;&lt;BR /&gt;
   proc sgrender data=sashelp.bweight template=sgplot7 ;&lt;BR /&gt;
      dynamic timevar="&amp;amp;_xvar" yvar="&amp;amp;_yvar" ;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
I have sent this to the SAS support and they replied we do not have any options to force or subset the data at the moment.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Makkena

Message was edited by: Makkena</description>
      <pubDate>Tue, 09 Mar 2010 16:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66068#M2254</guid>
      <dc:creator>Makkena</dc:creator>
      <dc:date>2010-03-09T16:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Plotting Logaxis values when the value is zero</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66069#M2255</link>
      <description>I would copy the X variable to an X2 column and replace all of the zeros with missing values. Then, use that column for your log axis. Let me know if that helps.&lt;BR /&gt;
&lt;BR /&gt;
Dan</description>
      <pubDate>Tue, 09 Mar 2010 16:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66069#M2255</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2010-03-09T16:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Plotting Logaxis values when the value is zero</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66070#M2256</link>
      <description>Thanks Dan. I have created a new variable by setting the &amp;lt;=0 values to missing. Unfortunately, that did not like it. I got a warning message in the log. The ScatterPlot statement named 'scat1' will not be drawn because one or more of the required arguments were not supplied.&lt;BR /&gt;
&lt;BR /&gt;
proc template;&lt;BR /&gt;
define statgraph sgplot7;&lt;BR /&gt;
dynamic __BYLINE__ _ticklist_ timevar yvar trtvar sidvar &lt;BR /&gt;
_title0 _title1 _title2 _title3  &lt;BR /&gt;
_title4 _title5 _title6 _title7 _title8 _title9 _title10&lt;BR /&gt;
_footnote1 _footnote2 _footnote3 _footnote4 _footnote5&lt;BR /&gt;
_footnote6 _footnote7 _footnote8 _footnote9 _footnote10;&lt;BR /&gt;
nmvar _xoffset_min _xoffset_max _xmin _xmax _xorder yvar1&lt;BR /&gt;
_yoffset_min _yoffset_max _ymin _ymax;&lt;BR /&gt;
&lt;BR /&gt;
begingraph;&lt;BR /&gt;
layout lattice /columns=2;&lt;BR /&gt;
&lt;BR /&gt;
layout overlay / xaxisopts=( &lt;BR /&gt;
type=linear offsetmin=_xoffset_min offsetmax=_xoffset_max &lt;BR /&gt;
linearopts=( /* tickvaluelist=(&amp;amp;_xorder) */&lt;BR /&gt;
viewmin=_xmin &lt;BR /&gt;
viewmax=_xmax )) &lt;BR /&gt;
yaxisopts=( &lt;BR /&gt;
type=linear offsetmin=_yoffset_min offsetmax=_yoffset_max &lt;BR /&gt;
linearopts=( viewmin=_ymin viewmax=_ymax )&lt;BR /&gt;
);&lt;BR /&gt;
ScatterPlot X=timevar Y=yvar / markerattrs=(color=black)&lt;BR /&gt;
LegendLabel="mean" &lt;BR /&gt;
NAME="scat";&lt;BR /&gt;
endlayout;&lt;BR /&gt;
cell; &lt;BR /&gt;
cellheader;&lt;BR /&gt;
entry "Semi-log" / textattrs=GraphLabelText;&lt;BR /&gt;
endcellheader;&lt;BR /&gt;
&lt;BR /&gt;
layout overlay / xaxisopts=( &lt;BR /&gt;
type=linear offsetmin=_xoffset_min offsetmax=_xoffset_max &lt;BR /&gt;
linearopts=( /* tickvaluelist=(&amp;amp;_xorder) */&lt;BR /&gt;
viewmin=_xmin &lt;BR /&gt;
viewmax=_xmax ))&lt;BR /&gt;
yaxisopts=( &lt;BR /&gt;
type=log &lt;BR /&gt;
logopts=( Base=10 ));&lt;BR /&gt;
&lt;BR /&gt;
ScatterPlot X=timevar Y=yvar1 markerattrs=(color=black)&lt;BR /&gt;
LegendLabel="mean" NAME="scat1";&lt;BR /&gt;
&lt;BR /&gt;
endlayout;&lt;BR /&gt;
endcell;&lt;BR /&gt;
endlayout;&lt;BR /&gt;
&lt;BR /&gt;
endgraph;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
title;&lt;BR /&gt;
footnote;&lt;BR /&gt;
&lt;BR /&gt;
%let _xvar=visit;&lt;BR /&gt;
let _yvar1=m_wtgain1;&lt;BR /&gt;
%let _yvar=m_wtgain;&lt;BR /&gt;
data weight;&lt;BR /&gt;
set sashelp.bweight;&lt;BR /&gt;
if m_wtgain le 0 then m_wtgain1=.;&lt;BR /&gt;
else m_wtgain1=m_wtgain;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sgrender data=weight template=sgplot7 ;&lt;BR /&gt;
dynamic timevar="&amp;amp;_xvar" yvar="&amp;amp;_yvar" yvar1="&amp;amp;_yvar1";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Setting bold is not displaying the whole message.&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Makkena

Removed bold&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Makkena</description>
      <pubDate>Tue, 09 Mar 2010 18:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66070#M2256</guid>
      <dc:creator>Makkena</dc:creator>
      <dc:date>2010-03-09T18:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Plotting Logaxis values when the value is zero</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66071#M2257</link>
      <description>hi ... so this is not a direct answer to the question, but just another way to look at the weight change data&lt;BR /&gt;
&lt;BR /&gt;
if you want a display of logs of weight change, you know that you'll have to 'throw away' the zero and negative numbers &lt;BR /&gt;
&lt;BR /&gt;
so, here's a non-GTL way of looking at the same data that looks slightly similar to your GTL plot&lt;BR /&gt;
&lt;BR /&gt;
weight change is always 0 or positive&lt;BR /&gt;
gain is blue, lose is red&lt;BR /&gt;
this gives a 'log look' at both weight gain and weight loss&lt;BR /&gt;
[pre]&lt;BR /&gt;
* &lt;BR /&gt;
rearranging data ... +/0 in one group, - in another&lt;BR /&gt;
two groups&lt;BR /&gt;
;&lt;BR /&gt;
data bwt;&lt;BR /&gt;
set sashelp.bweight (keep=visit m_wtgain);&lt;BR /&gt;
select;&lt;BR /&gt;
   when (m_wtgain ge 0) do; group=1; lvisit=3*visit;   end;&lt;BR /&gt;
   when (m_wtgain lt 0) do; group=2; lvisit=3*visit+1; end;&lt;BR /&gt;
end;&lt;BR /&gt;
lm_wtgain = abs(m_wtgain);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* some SAS/Graph options;&lt;BR /&gt;
goptions reset=all ftext="calibri" htext=1&lt;BR /&gt;
device=gif xpixels=1000 ypixels=1000 gsfname=gout ;&lt;BR /&gt;
&lt;BR /&gt;
axis1 label=(a=90 "MOM'S WEIGHT CHANGE (POUNDS)");&lt;BR /&gt;
&lt;BR /&gt;
axis2 label=(a=90 "MOM'S WEIGHT CHANGE (POUNDS, LOG SCALE)") &lt;BR /&gt;
logbase=10;&lt;BR /&gt;
&lt;BR /&gt;
axis3 offset=(5,5)pct minor=none order=-0 to 10 by 1 &lt;BR /&gt;
         major=(c=white) label=('VISIT')&lt;BR /&gt;
         value=(&lt;BR /&gt;
  tick=1  c=blue j=c "0" j=c "GAIN" tick=2  c=red j=c "0" j=c "LOSE" tick=3  ""&lt;BR /&gt;
  tick=4  c=blue j=c "1" j=c "GAIN" tick=5  c=red j=c "1" j=c "LOSE" tick=6  ""&lt;BR /&gt;
  tick=7  c=blue j=c "2" j=c "GAIN" tick=8  c=red j=c "2" j=c "LOSE" tick=9  ""&lt;BR /&gt;
  tick=10 c=blue j=c "3" j=c "GAIN" tick=11 c=red j=c "3" j=c "LOSE" tick=12 "");&lt;BR /&gt;
&lt;BR /&gt;
symbol1 v=dot h=1 c=blue;&lt;BR /&gt;
symbol2 v=dot h=1 c=red;&lt;BR /&gt;
&lt;BR /&gt;
* for white space around the chart;&lt;BR /&gt;
title1 ls=1;&lt;BR /&gt;
title2 ls=1 a=90;&lt;BR /&gt;
title3 ls=1 a=-90;&lt;BR /&gt;
footnote1 ls=1;&lt;BR /&gt;
&lt;BR /&gt;
*&lt;BR /&gt;
 two plots ... one regular, one log (base 10)&lt;BR /&gt;
not printed ... used later in GREPLAY&lt;BR /&gt;
;&lt;BR /&gt;
filename gout dummy;&lt;BR /&gt;
&lt;BR /&gt;
proc gplot data=bwt gout=plots;&lt;BR /&gt;
plot lm_wtgain*lvisit=group / vaxis=axis1 haxis=axis3 nolegend name='one';&lt;BR /&gt;
run;&lt;BR /&gt;
plot lm_wtgain*lvisit=group / vaxis=axis2 haxis=axis3 nolegend name='two';&lt;BR /&gt;
where lm_wtgain ne 0;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
goptions xpixels=2000;&lt;BR /&gt;
&lt;BR /&gt;
* destination for output;&lt;BR /&gt;
filename gout "z:\bwt.gif";&lt;BR /&gt;
&lt;BR /&gt;
proc greplay igout=plots nofs;&lt;BR /&gt;
tc sashelp.templt;&lt;BR /&gt;
template h2;&lt;BR /&gt;
tplay 1:one 2:two; &lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
* chance to use KILL in SAS;&lt;BR /&gt;
proc catalog c=plots kill;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 09 Mar 2010 20:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66071#M2257</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2010-03-09T20:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Plotting Logaxis values when the value is zero</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66072#M2258</link>
      <description>Thanks Mike for your response. I have no issue with Non-GTL language which we had it already. I am using the new SG procedures and GTL language totake the advatange of the Graphics quality.&lt;BR /&gt;
Dan, I see for some reason my early response was not posted properly. The solution you proposed did not work.&lt;BR /&gt;
Thanks for all your replies,&lt;BR /&gt;
Makkena</description>
      <pubDate>Wed, 10 Mar 2010 14:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plotting-Logaxis-values-when-the-value-is-zero/m-p/66072#M2258</guid>
      <dc:creator>Makkena</dc:creator>
      <dc:date>2010-03-10T14:05:40Z</dc:date>
    </item>
  </channel>
</rss>

