<?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 Calculate percentage for a group in SAS Viya (2025.02) using the '+ New data item' window in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/Calculate-percentage-for-a-group-in-SAS-Viya-2025-02-using-the/m-p/971530#M2931</link>
    <description>&lt;P&gt;Data items:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;tsstate_datetime (in minutes)&lt;/LI&gt;&lt;LI&gt;cat_latency_groepen (categorie, 7 groups)&lt;/LI&gt;&lt;LI&gt;aantal (count per group).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like to calculate percentage of the first group (lat_0_2) of the total per datetime value( minute, hour, day etc.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I now how to do it in normal SAS code, using the 'New data item ' window isn't s&lt;SPAN&gt;traightforward at all&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function should be something like:&lt;/P&gt;&lt;P&gt;SUM(IF ('cat_latency_groepen'n IN ('lat_0_2'), 'aantal'n, 0)) / SUM('aantal'n) * 100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I also tried using IF....ELSE operator as well but that starts off with a IF underneath red. I have no clue using this operator in this interface. And I can't find any helpfull documentation.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the best practice using &lt;U&gt;this interface&lt;/U&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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="SAS2.JPG" style="width: 842px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108576iB5285A7ADD55DBF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS2.JPG" alt="SAS2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS1.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108575iF67ADF754CEB98BD/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS1.JPG" alt="SAS1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Jul 2025 12:11:58 GMT</pubDate>
    <dc:creator>FBAC</dc:creator>
    <dc:date>2025-07-27T12:11:58Z</dc:date>
    <item>
      <title>Calculate percentage for a group in SAS Viya (2025.02) using the '+ New data item' window</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Calculate-percentage-for-a-group-in-SAS-Viya-2025-02-using-the/m-p/971530#M2931</link>
      <description>&lt;P&gt;Data items:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;tsstate_datetime (in minutes)&lt;/LI&gt;&lt;LI&gt;cat_latency_groepen (categorie, 7 groups)&lt;/LI&gt;&lt;LI&gt;aantal (count per group).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like to calculate percentage of the first group (lat_0_2) of the total per datetime value( minute, hour, day etc.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I now how to do it in normal SAS code, using the 'New data item ' window isn't s&lt;SPAN&gt;traightforward at all&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function should be something like:&lt;/P&gt;&lt;P&gt;SUM(IF ('cat_latency_groepen'n IN ('lat_0_2'), 'aantal'n, 0)) / SUM('aantal'n) * 100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I also tried using IF....ELSE operator as well but that starts off with a IF underneath red. I have no clue using this operator in this interface. And I can't find any helpfull documentation.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the best practice using &lt;U&gt;this interface&lt;/U&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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="SAS2.JPG" style="width: 842px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108576iB5285A7ADD55DBF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS2.JPG" alt="SAS2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS1.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108575iF67ADF754CEB98BD/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS1.JPG" alt="SAS1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jul 2025 12:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Calculate-percentage-for-a-group-in-SAS-Viya-2025-02-using-the/m-p/971530#M2931</guid>
      <dc:creator>FBAC</dc:creator>
      <dc:date>2025-07-27T12:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage for a group in SAS Viya (2025.02) using the '+ New data item' window</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Calculate-percentage-for-a-group-in-SAS-Viya-2025-02-using-the/m-p/971532#M2932</link>
      <description>&lt;P&gt;This seems to work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum(ByGroup, IF In(cat_latency_groepen, 'lat_0_2') RETURN aantal ELSE 0) /Sum(ByGroup, 'aantal'n)&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jul 2025 12:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Calculate-percentage-for-a-group-in-SAS-Viya-2025-02-using-the/m-p/971532#M2932</guid>
      <dc:creator>FBAC</dc:creator>
      <dc:date>2025-07-27T12:40:04Z</dc:date>
    </item>
  </channel>
</rss>

