<?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: How to plot a histogram with a log scale y axis when baseline = doesn't work in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553325#M18031</link>
    <description>&lt;P&gt;Yes, you have the first release of SAS 9.4, without any maintenance updates.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2019 16:05:15 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2019-04-23T16:05:15Z</dc:date>
    <item>
      <title>How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553067#M18027</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a histogram where both the x and y axes are on the log scale so that I can determine whether my variable is power-law distributed. Essentially, I only have one variable which is a count variable of the number of "likes" for each comment on a Nike YouTube video. Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;title 'Histogram of Logged "Likes" for the Nike YouTube Video';&lt;/DIV&gt;&lt;DIV&gt;proc sgplot data = twopart;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;where Video = "Nike";&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;vbar loglikes / groupdisplay = cluster baseline=.0000001;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;yaxis type = log logbase = 10;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I simply log transformed my variable to get the x axis on the log scale, but I'm having trouble transforming the y axis. I've read a few other posts that say the best thing to do when your axis contains zeros is to use the baseline = option, but I keep getting an error message that says:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2664 vbar loglikes / groupdisplay = cluster baseline=.0000001;&lt;BR /&gt;--------&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ALPHA, ATTRID, BARWIDTH,&lt;BR /&gt;CATEGORYORDER, CLUSTERWIDTH, DATALABEL, DATALABELATTRS, DATALABELFITPOLICY,&lt;BR /&gt;DATALABELPOS, DATASKIN, DISCRETEOFFSET, FILL, FILLATTRS, FREQ, GROUP,&lt;BR /&gt;GROUPDISPLAY, GROUPORDER, LEGENDLABEL, LIMITATTRS, LIMITS, LIMITSTAT,&lt;BR /&gt;MISSING, NAME, NOFILL, NOOUTLINE, NOSTATLABEL, NUMSTD, OUTLINE,&lt;BR /&gt;OUTLINEATTRS, RESPONSE, SPLITCHAR, SPLITCHARNODROP, STAT, TIP, TIPFORMAT,&lt;BR /&gt;TIPLABEL, TRANSPARENCY, URL, WEIGHT, X2AXIS, Y2AXIS.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS version 9.4.&lt;/P&gt;&lt;P&gt;I would greatly appreciate any help. Thank you!&lt;/P&gt;&lt;P&gt;Madeline&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 21:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553067#M18027</guid>
      <dc:creator>mcraft</dc:creator>
      <dc:date>2019-04-22T21:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553270#M18029</link>
      <description>&lt;P&gt;The BASELINE option was introduced for bar charts in SAS 9.4m1. Do you have SAS 9.4 without any maintenance updates? What does the following give you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;sysvlong;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 14:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553270#M18029</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-04-23T14:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553297#M18030</link>
      <description>&lt;P&gt;Thank you for your quick response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following:&lt;/P&gt;&lt;P&gt;9.04.01M0P061913&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 15:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553297#M18030</guid>
      <dc:creator>mcraft</dc:creator>
      <dc:date>2019-04-23T15:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553325#M18031</link>
      <description>&lt;P&gt;Yes, you have the first release of SAS 9.4, without any maintenance updates.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 16:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/553325#M18031</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-04-23T16:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/554287#M18044</link>
      <description>&lt;P&gt;From the variable name (loglikes), it sounds like you have already transformed the response variable. If so, you can use a regular linear Y axis and simply use LABEL='log likes' to indicate that the axis is on a log scale.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use a log axis on data that has already been log-transformed, you will be viewing doubly-logged data.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/554287#M18044</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-04-26T14:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/554318#M18046</link>
      <description>&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I would like to create a doubly-logged plot. I'm trying to determine whether my variable "likes" follows a power-law distribution, so I've taken the log of "likes" and now I need to view it on a logged y axis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My understanding is that I'd be able to create a log-log plot if I could use the baseline = log option, but my version of SAS isn't a candidate for maintenance updates.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 15:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/554318#M18046</guid>
      <dc:creator>mcraft</dc:creator>
      <dc:date>2019-04-26T15:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/554347#M18047</link>
      <description>&lt;P&gt;I don't advocate using a doubly-logged Y variable, but if you choose to do so, you can use the data step to compute&lt;/P&gt;
&lt;P&gt;LogLogLikes = log10(log10(likes));&lt;/P&gt;
&lt;P&gt;and then use a linear scale on the vertical bar height.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, you can transform the Y any way you want. You also need to bin the data yourself (which I assume you've already don) and then run&lt;/P&gt;
&lt;P&gt;VBAR xBin / response=LogLogLikes;&lt;/P&gt;
&lt;P&gt;This will emulate the histogram with a transformed Y axis.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 17:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/554347#M18047</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-04-26T17:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730495#M21250</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a similar problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have obtained the histogram bins from PROC UNIVARIATE, and my goal is to plot the output dataset as an histogram with a Log Y axis using PROC SGPLOT with VBAR and BASELINE=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is that VBAR adds its own ticks and labels, and the resulting plot is illegible:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VoterTurnout43GE27.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56753i4E772644DC0C539E/image-size/large?v=v2&amp;amp;px=999" role="button" title="VoterTurnout43GE27.png" alt="VoterTurnout43GE27.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So my question is the following: Is there a way to prevent VBAR to show the bar labels?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 20:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730495#M21250</guid>
      <dc:creator>gabonzo</dc:creator>
      <dc:date>2021-03-31T20:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730716#M21256</link>
      <description>&lt;P&gt;To get rid of the axis labels, just add the following statement to SGPLOT:&lt;/P&gt;
&lt;P&gt;xaxis display=none;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 14:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730716#M21256</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2021-04-01T14:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730720#M21257</link>
      <description>&lt;P&gt;Oh weird I thought I had tried it, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 14:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730720#M21257</guid>
      <dc:creator>gabonzo</dc:creator>
      <dc:date>2021-04-01T14:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730727#M21258</link>
      <description>&lt;P&gt;I have implemented a workaround that generates a histogram-like plot.&lt;/P&gt;
&lt;P&gt;It works like this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You first obtain a dataset with bin data from PROC UNIVARIATE&lt;/LI&gt;
&lt;LI&gt;If any bin is equal to zero, you add a small nonzero value (e.g. 1e-9)&lt;/LI&gt;
&lt;LI&gt;You use PROC SGPLOT to plot a STEP line, which will be the outline of your "histogram"&lt;/LI&gt;
&lt;LI&gt;In the same PROC SGPLOT block, you use a BAND statement to fill the area below the outline&lt;/LI&gt;
&lt;LI&gt;You give the y axis a lower limit of 1e-1&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The result looks like this, with some minor tweaks it can pass as a histogram:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VoterTurnout43GE67.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56801i9B83B49031906E77/image-size/large?v=v2&amp;amp;px=999" role="button" title="VoterTurnout43GE67.png" alt="VoterTurnout43GE67.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;And here's the macro that does it:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro plot_logy_histo(inData=, var=,  title=, debug=0);

	%local bindat;

	/* create dataset with bin contents */
	proc univariate data=&amp;amp;inData. noprint;
		histogram &amp;amp;var. / vscale=count outhistogram=_DATA_(label=plot_logy_histo bindat) noplot;
	run;
	%let bindat=&amp;amp;SYSLAST.;

	/* add dummy data to zero bins */
	data &amp;amp;bindat.;
		set &amp;amp;bindat.;
		if _count_ eq 0 then _count_=_count_+1e-9;
	run;

	proc sgplot data=&amp;amp;bindat. noautolegend;
		title "&amp;amp;title.";
		yaxis logbase=10 type=log min=1e-1 label="Number of Polling Divisions";
		xaxis valuesformat=percentn7. label="Percentage";
		step x=_midpt_ y=_count_ / lineattrs=(thickness=0) name = "outline";
	  	band x=_midpt_ upper=_count_ lower=1e-9 / outline fill modelname="outline" fillattrs=(color=&amp;amp;ec_burgundy.);
	run;
	title;

	%if &amp;amp;debug. eq 0 %then %do;
		proc delete data=&amp;amp;bindat.;
		run;
	%end;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Apr 2021 14:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730727#M21258</guid>
      <dc:creator>gabonzo</dc:creator>
      <dc:date>2021-04-01T14:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730779#M21261</link>
      <description>&lt;P&gt;Why not just replace zero counts with a missing value?&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;if _count_ eq 0 then _count_=.;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 16:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730779#M21261</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-04-01T16:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730780#M21262</link>
      <description>I haven't tried that, it should work too. Thanks!</description>
      <pubDate>Thu, 01 Apr 2021 16:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730780#M21262</guid>
      <dc:creator>gabonzo</dc:creator>
      <dc:date>2021-04-01T16:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot a histogram with a log scale y axis when baseline = doesn't work</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730781#M21263</link>
      <description>&lt;P&gt;Actually, setting _count_=. has an unpleasant side effect: if the data for a bin is missing, STEP will interpolate the missing data from the neighbouring bins.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I think it's better to add a small nonzero value: this forces STEP to go below the visible y axis range.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 16:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-plot-a-histogram-with-a-log-scale-y-axis-when-baseline/m-p/730781#M21263</guid>
      <dc:creator>gabonzo</dc:creator>
      <dc:date>2021-04-01T16:55:14Z</dc:date>
    </item>
  </channel>
</rss>

