<?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: Displaying Values for Histograms in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/843012#M23263</link>
    <description>&lt;P&gt;Your going to need to look at the histogram to set some limits but see if this gets you close. Since you want to display Year values then the obvious choice is a TEXT plot, which uses an X, Y pair for coordinates and allows some offset position values. So round the Return value to get plot groups, sort, add in a Y value that increments for each year of data.&lt;/P&gt;
&lt;P&gt;Caution: the amount of space you use may not allow all the text and you may have to adjust the increment for the Yval.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data return2;
	set return;
	by year;
	if last.year;
	return=adj_close/lag(adj_close)-1;
   xplot= round(return,0.1);
run;
proc sort data=return2;
   by xplot year;
run;


data toplot;
   set return2;
   by xplot year;
   retain yval ;
   if first.xplot then yval=0;
   else yval+1;
run;

proc sgplot data=toplot;
   text x=xplot y=yval text=year/ 
             position=topright;
	xaxis values=(-.8 to .9 by .1) label='Return';
   label yval='Year count';
run;
&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Nov 2022 23:47:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-11-07T23:47:30Z</dc:date>
    <item>
      <title>Displaying Values for Histograms</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/842988#M23262</link>
      <description>&lt;P&gt;The following histogram uses the year labels of observations:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Histogram.png" style="width: 698px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77046iD766F82C5D229939/image-size/large?v=v2&amp;amp;px=999" role="button" title="Histogram.png" alt="Histogram.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can I do something similar to this in SAS? Here is a non-labeled replication using SGPLOT HISTOGRAM.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Example.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77047i9FB251CE2FD557A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Example.png" alt="Example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here I attach the snippet; in addition, I also wonder if the vertical bars can be drawn not centered around tick marks but in between two tick marks.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename raw url 'https://query1.finance.yahoo.com/v7/finance/download/%5EGSPC?period1=-9999999999&amp;amp;period2=99999999999';

proc import file=raw dbms=csv replace out=raw;
run;

data return;
	set raw;
	year=year(date);
data return;
	set return;
	by year;
	if last.year;
	return=adj_close/lag(adj_close)-1;
run;

ods results=off;
ods listing gpath='!userprofile\desktop';
ods graphics/reset noborder imagename='Example';

proc sgplot;
	where 1926&amp;lt;=year&amp;lt;=2017;
	histogram return/binstart=-.8 binwidth=.1 nbins=17 scale=count;
	xaxis values=(-.8 to .9 by .1) label='Return';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 21:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/842988#M23262</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2022-11-07T21:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying Values for Histograms</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/843012#M23263</link>
      <description>&lt;P&gt;Your going to need to look at the histogram to set some limits but see if this gets you close. Since you want to display Year values then the obvious choice is a TEXT plot, which uses an X, Y pair for coordinates and allows some offset position values. So round the Return value to get plot groups, sort, add in a Y value that increments for each year of data.&lt;/P&gt;
&lt;P&gt;Caution: the amount of space you use may not allow all the text and you may have to adjust the increment for the Yval.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data return2;
	set return;
	by year;
	if last.year;
	return=adj_close/lag(adj_close)-1;
   xplot= round(return,0.1);
run;
proc sort data=return2;
   by xplot year;
run;


data toplot;
   set return2;
   by xplot year;
   retain yval ;
   if first.xplot then yval=0;
   else yval+1;
run;

proc sgplot data=toplot;
   text x=xplot y=yval text=year/ 
             position=topright;
	xaxis values=(-.8 to .9 by .1) label='Return';
   label yval='Year count';
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Nov 2022 23:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/843012#M23263</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-07T23:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying Values for Histograms</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/843090#M23265</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
I like this picture.
*/
data have;
call streaminit(123);
do year=1926 to 2022;
 return=rand('normal');
 output;
end;
run;
proc sql;
create table have2 as
select year,(return-min(return))/(range(return)+0.5)-0.4 as return
 from have;
quit;
data have3;
 set have2;
 x=round(100*return,10)-5;
run;
proc sort data=have3 out=have4;
by x year;
run;
data have5;
 set have4;
 by x;
 if first.x then y=0;
 y+1;
run;





proc sgplot data=have5;
scatter x=x y=y/markerchar=year markercharattrs=(size=10 ) labelstrip;
xaxis values=(-90 to 90 by 10) min=-90 max=90 valueshint;
yaxis display=none offsetmin=0 offsetmax=0.1 min=1.6 valueshint;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1667907334963.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77074i7705EE08FD66E26F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1667907334963.png" alt="Ksharp_0-1667907334963.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 11:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Displaying-Values-for-Histograms/m-p/843090#M23265</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-11-08T11:35:07Z</dc:date>
    </item>
  </channel>
</rss>

