<?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 PROC SGPANEL: Include Zero Counts for GROUP Variable, Compress Zero Counts for PANELBY Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913031#M359884</link>
    <description>&lt;P&gt;From my extensive Google searching, I have not been able to find a solution to this problem.&amp;nbsp; I am wondering if what I want to do is possible in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a rather large graph.&amp;nbsp; I basically have 3 grouping variables.&amp;nbsp; The first is number of variants (0 or 1).&amp;nbsp; This variable determines the bars.&amp;nbsp; The second group is investigator site.&amp;nbsp; This clusters the bars together.&amp;nbsp; The third is country.&amp;nbsp; This is a panelby variable.&amp;nbsp; Below is the code that I am using (sample data attached).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / reset width=10in height=4in;
proc sgpanel data=site;&lt;BR /&gt;/*	where country in ('BR','CO'); */
	panelby country / onepanel layout=columnlattice colheaderpos=bottom noborder novarname; 
	vbar siteid / group=nvariants groupdisplay=cluster grouporder=data;
	rowaxis display=(nolabel);
	colaxis display=(nolabel);   
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running into 2 issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;When a group is not available for the group variable (NVARIANTS), it compresses the empty spaces and centers the bars.&amp;nbsp; I want the zero space left blank.&amp;nbsp; Notice how the tick mark for Brazil sites 016 and 018 is inbetween the 2 bars, but for sites 005 and 015, it compresses the empty bar and centers the remaining bar (no space for a zero count bar).&amp;nbsp; From my understanding, there is no way to make this happen in SAS.&lt;/LI&gt;
&lt;LI&gt;The panelby variable (COUNTRY) creates a space for every site even if it's not available in that country.&amp;nbsp; Notice that Brazil has an empty space for sites 395 and 396.&amp;nbsp; Also, notice that Colombia is displaying several empty sites (because these are from Brazil and not Colombia).&amp;nbsp; This is basically what I want to have happen in my first issue, but I don't want it here.&amp;nbsp; I want to only display sites applicable to the associated country.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Subgroup of my graph:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="djbateman_0-1706208277536.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92979i77D7241F18C51041/image-size/large?v=v2&amp;amp;px=999" role="button" title="djbateman_0-1706208277536.png" alt="djbateman_0-1706208277536.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, I want to swap what is happening in both issues.&amp;nbsp; I want NVARIANTS to create a spot for each possibilitiy, even if it's not there, but I want it to NOT create a spot for each site unless it is found in that country.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I get on my full data (very cluttered):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="djbateman_2-1706207679385.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92978i6496D67783A97139/image-size/large?v=v2&amp;amp;px=999" role="button" title="djbateman_2-1706207679385.png" alt="djbateman_2-1706207679385.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this is what I want the graph to look like (generated manually in Excel, butI have been asked to automate in SAS):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="djbateman_0-1706206725767.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92976i555F09BF50672145/image-size/large?v=v2&amp;amp;px=999" role="button" title="djbateman_0-1706206725767.png" alt="djbateman_0-1706206725767.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2024 18:49:57 GMT</pubDate>
    <dc:creator>djbateman</dc:creator>
    <dc:date>2024-01-25T18:49:57Z</dc:date>
    <item>
      <title>PROC SGPANEL: Include Zero Counts for GROUP Variable, Compress Zero Counts for PANELBY Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913031#M359884</link>
      <description>&lt;P&gt;From my extensive Google searching, I have not been able to find a solution to this problem.&amp;nbsp; I am wondering if what I want to do is possible in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a rather large graph.&amp;nbsp; I basically have 3 grouping variables.&amp;nbsp; The first is number of variants (0 or 1).&amp;nbsp; This variable determines the bars.&amp;nbsp; The second group is investigator site.&amp;nbsp; This clusters the bars together.&amp;nbsp; The third is country.&amp;nbsp; This is a panelby variable.&amp;nbsp; Below is the code that I am using (sample data attached).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / reset width=10in height=4in;
proc sgpanel data=site;&lt;BR /&gt;/*	where country in ('BR','CO'); */
	panelby country / onepanel layout=columnlattice colheaderpos=bottom noborder novarname; 
	vbar siteid / group=nvariants groupdisplay=cluster grouporder=data;
	rowaxis display=(nolabel);
	colaxis display=(nolabel);   
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running into 2 issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;When a group is not available for the group variable (NVARIANTS), it compresses the empty spaces and centers the bars.&amp;nbsp; I want the zero space left blank.&amp;nbsp; Notice how the tick mark for Brazil sites 016 and 018 is inbetween the 2 bars, but for sites 005 and 015, it compresses the empty bar and centers the remaining bar (no space for a zero count bar).&amp;nbsp; From my understanding, there is no way to make this happen in SAS.&lt;/LI&gt;
&lt;LI&gt;The panelby variable (COUNTRY) creates a space for every site even if it's not available in that country.&amp;nbsp; Notice that Brazil has an empty space for sites 395 and 396.&amp;nbsp; Also, notice that Colombia is displaying several empty sites (because these are from Brazil and not Colombia).&amp;nbsp; This is basically what I want to have happen in my first issue, but I don't want it here.&amp;nbsp; I want to only display sites applicable to the associated country.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Subgroup of my graph:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="djbateman_0-1706208277536.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92979i77D7241F18C51041/image-size/large?v=v2&amp;amp;px=999" role="button" title="djbateman_0-1706208277536.png" alt="djbateman_0-1706208277536.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, I want to swap what is happening in both issues.&amp;nbsp; I want NVARIANTS to create a spot for each possibilitiy, even if it's not there, but I want it to NOT create a spot for each site unless it is found in that country.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I get on my full data (very cluttered):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="djbateman_2-1706207679385.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92978i6496D67783A97139/image-size/large?v=v2&amp;amp;px=999" role="button" title="djbateman_2-1706207679385.png" alt="djbateman_2-1706207679385.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this is what I want the graph to look like (generated manually in Excel, butI have been asked to automate in SAS):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="djbateman_0-1706206725767.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92976i555F09BF50672145/image-size/large?v=v2&amp;amp;px=999" role="button" title="djbateman_0-1706206725767.png" alt="djbateman_0-1706206725767.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 18:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913031#M359884</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2024-01-25T18:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPANEL: Include Zero Counts for GROUP Variable, Compress Zero Counts for PANELBY Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913083#M359901</link>
      <description>&lt;P&gt;How about this one ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='c:\temp\BarChartSampleData.xlsx' out=have dbms=xlsx replace;
run;



ods graphics /width=1200px height=600px;
proc sgplot data=have;
where NVARIANTS ne '.';
styleattrs datacolors=(darkred grey);
vbarbasic INVNAME/group=NVARIANTS stat=freq groupdisplay=cluster nooutline  ;
block x=INVNAME block=COUNTRY/nofill labelattrs=(size=40 weight=bold);
xaxis fitpolicy=rotate VALUESROTATE=VERTICAL label='Country/PI';
yaxis grid label='Subject Counts';
keylegend /title='' noborder autooutline;
quit;
&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-1706248527529.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92992iE553C39B3061B6F6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1706248527529.png" alt="Ksharp_0-1706248527529.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 05:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913083#M359901</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-01-26T05:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPANEL: Include Zero Counts for GROUP Variable, Compress Zero Counts for PANELBY Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913133#M359921</link>
      <description>&lt;P&gt;You are a genius.&amp;nbsp; I don't think I would have figured all this out even after weeks of researching online.&amp;nbsp; This saved me a ton of time.&amp;nbsp; I used to be very proficient in SAS graphs, but after I left my first employer 8 years ago, I haven't used graphs much, and I have lost a lot of my skills.&amp;nbsp; Thank you so much for the refresher course.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 15:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPANEL-Include-Zero-Counts-for-GROUP-Variable-Compress/m-p/913133#M359921</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2024-01-26T15:22:30Z</dc:date>
    </item>
  </channel>
</rss>

