<?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 Histogram by group with lines instead of bars in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894716#M353427</link>
    <description>&lt;DIV id="bodyDisplay_29e4eeb2660b84" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I've created a graph from my data that is an overlaid histogram (HISTOGRAM statement). Here is my code:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sgplot data=data;
styleattrs datacolors=(Blue Green Red VLIP DEYBR Yellow) backcolor=white wallcolor=white;
where race ~=''; 
format race $race.;histogram Week / 
group=race transparency=0.5;
xaxis label='#Weeks' LABELATTRS=(size=14) VALUEATTRS=(size=13);
keylegend  / 
title='Weeks by race' TITLEATTRS=(size=16) valueattrs=(size=12); 
yaxis LABELATTRS=(size=14) VALUEATTRS=(size=13) grid GRIDATTRS=(color=LIGGR);
run;&lt;/LI-CODE&gt;
&lt;P&gt;Here is the graph that is produced:&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="confooseddesi89_2-1694987532266.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88113iD7881E52B9582FD7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="confooseddesi89_2-1694987532266.png" alt="confooseddesi89_2-1694987532266.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to produce the same exact graph, except with lines instead of vertical bars (e.g., sgplot type "series"). I've tried a series graph, but a "y" variable is required, and there is only one variable in this graph (other than the "by" group) with the percent on the y-axis. I've Googled around and can't seem to find a solution. Can you help? Thanks.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Sun, 17 Sep 2023 21:56:41 GMT</pubDate>
    <dc:creator>confooseddesi89</dc:creator>
    <dc:date>2023-09-17T21:56:41Z</dc:date>
    <item>
      <title>Histogram by group with lines instead of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894716#M353427</link>
      <description>&lt;DIV id="bodyDisplay_29e4eeb2660b84" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I've created a graph from my data that is an overlaid histogram (HISTOGRAM statement). Here is my code:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sgplot data=data;
styleattrs datacolors=(Blue Green Red VLIP DEYBR Yellow) backcolor=white wallcolor=white;
where race ~=''; 
format race $race.;histogram Week / 
group=race transparency=0.5;
xaxis label='#Weeks' LABELATTRS=(size=14) VALUEATTRS=(size=13);
keylegend  / 
title='Weeks by race' TITLEATTRS=(size=16) valueattrs=(size=12); 
yaxis LABELATTRS=(size=14) VALUEATTRS=(size=13) grid GRIDATTRS=(color=LIGGR);
run;&lt;/LI-CODE&gt;
&lt;P&gt;Here is the graph that is produced:&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="confooseddesi89_2-1694987532266.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88113iD7881E52B9582FD7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="confooseddesi89_2-1694987532266.png" alt="confooseddesi89_2-1694987532266.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to produce the same exact graph, except with lines instead of vertical bars (e.g., sgplot type "series"). I've tried a series graph, but a "y" variable is required, and there is only one variable in this graph (other than the "by" group) with the percent on the y-axis. I've Googled around and can't seem to find a solution. Can you help? Thanks.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 17 Sep 2023 21:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894716#M353427</guid>
      <dc:creator>confooseddesi89</dc:creator>
      <dc:date>2023-09-17T21:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram by group with lines instead of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894731#M353436</link>
      <description>&lt;P&gt;Sometimes what you want just is not possible with the data that you have and it requires adding a variable or restructuring the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So first step is to provide the data values to plot. Any other plot I can think of is going to require grouping. HISTOGRAM plots do that with parameters related to bid widths and such. If you want a similar grouped plot then you have to provide the "bins" or grouping values. Typically the easiest way to group values is with a format but without knowing the exact groups you want cannot suggest one.&lt;/P&gt;
&lt;P&gt;You can try outputting the data that the current graph creates to plot with using ODS OUTPUT. But that will still require you to make decisions.&lt;/P&gt;
&lt;P&gt;Since you did not supply any data here is an example of creating a data set with a HISTOGRAM plot that uses a data set that should have been installed with your SAS installation:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.heart;
   ods output sgplot=plotdata;
   histogram ageatstart/group=status ;
run;&lt;/PRE&gt;
&lt;P&gt;And making a series graph from that output set:&lt;/P&gt;
&lt;PRE&gt;proc sort data=plotdata;
   by status BIN_AGEATSTART_GROUP_STATUS___X;
run;

proc sgplot data=plotdata;
   series  x=BIN_AGEATSTART_GROUP_STATUS___X
           y=BIN_AGEATSTART_GROUP_STATUS___Y
           /group = status;
run;
&lt;/PRE&gt;
&lt;P&gt;You can skip the sort but I guarantee you won't like the result because of the way that Historgram summarized the result for this particular set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I had wanted a series graph I would almost certainly &lt;STRONG&gt;NOT&lt;/STRONG&gt; used Histogram to create the data set but created my own summary based on the values of age I though were useful/important or had some existing impact on the data base on knowledge of the topic.&lt;/P&gt;
&lt;P&gt;Then create a format for the Age group boundaries I wanted and summarize the data with that:&lt;/P&gt;
&lt;P&gt;Note: I intentionally did not create an age grouping format for this data set because I don't need to, I don't really care what the plot might look like.&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.heart noprint;
   tables status*ageatstart/ out=myplotdata;
   format ageatstart myageformat.;
run;

proc sgplot data=myplotdata;
   series x=ageatstart y=count/group=status;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 04:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894731#M353436</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-18T04:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram by group with lines instead of bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894762#M353449</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
You need calcualted it before plot it.
*/
data have;
 set sashelp.heart;
 if ageatstart&amp;gt;50;
run;

proc sort data=have;by ageatstart ;run;
proc freq data=have noprint;
by ageatstart;
table bp_status/ out=want;
run;

proc sgplot data=want;
series x=ageatstart y=PERCENT/group=bp_status;
xaxis type=discrete integer;
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-1695036671650.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88119iA6804E31699466D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1695036671650.png" alt="Ksharp_0-1695036671650.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 11:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-by-group-with-lines-instead-of-bars/m-p/894762#M353449</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-09-18T11:30:37Z</dc:date>
    </item>
  </channel>
</rss>

