<?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: Sum variables by row if they respect a condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811431#M33917</link>
    <description>&lt;P&gt;Same answer as in your previous thread&amp;nbsp;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Group-all-observation-for-a-given-year-and-a-given-country/m-p/810323" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Group-all-observation-for-a-given-year-and-a-given-country/m-p/810323&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PROC SUMMARY.&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 13:04:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-05-04T13:04:44Z</dc:date>
    <item>
      <title>Sum variables by row if they respect a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811429#M33916</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm after some assistance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to sum the total_casualties if the same type of disaster occurs twice (or more) in the same year. My dataset looks approximately like this one:&lt;/P&gt;&lt;PRE&gt;   Country  Year Disaster_type  Total_casualties
Afghanistan 1990     Flood           2134
Afghanistan 1990     Flood           3456
Afghanistan 1993    Epidemic         111
...
Afghanistan 2020     Storm           345
Albania     1992    Landslide        222
Albania     1992    Landslide        111
Albania     1994     Storm           555
...
Albania     2014    Epidemic         5675&lt;/PRE&gt;&lt;P&gt;What I want to obtain is a dataset like this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Country  Year Disaster_type  Total_casualties
Afghanistan 1990     Flood           5590
Afghanistan 1993    Epidemic         111
...
Afghanistan 2020     Storm           345
Albania     1992    Landslide        333
Albania     1994     Storm           555
...
Albania     2014    Epidemic         5675&lt;/PRE&gt;&lt;P&gt;Note that now the the total casualties in "Afghanistan 1990 Flood" is the sum of the same disaster type occurred twice in Afghanistan in the same year (the same in Albania 1992 landslide). How can I obtain this?&lt;/P&gt;&lt;P&gt;Any help is highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 12:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811429#M33916</guid>
      <dc:creator>alsi21ac</dc:creator>
      <dc:date>2022-05-04T12:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sum variables by row if they respect a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811431#M33917</link>
      <description>&lt;P&gt;Same answer as in your previous thread&amp;nbsp;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Group-all-observation-for-a-given-year-and-a-given-country/m-p/810323" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Group-all-observation-for-a-given-year-and-a-given-country/m-p/810323&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PROC SUMMARY.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 13:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811431#M33917</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-04T13:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sum variables by row if they respect a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811432#M33918</link>
      <description>&lt;P&gt;Maxim 7: There Is a Procedure for It.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
class country year disaster_type;
var total_casualties;
output out=want (drop=_type_) sum()=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 May 2022 13:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sum-variables-by-row-if-they-respect-a-condition/m-p/811432#M33918</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-04T13:07:31Z</dc:date>
    </item>
  </channel>
</rss>

