<?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: Aggregation of Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839222#M331836</link>
    <description>I need to match the exact month, day, and year for the seizure date (similar dates) to the drug and then the county where it was seized.&lt;BR /&gt;&lt;BR /&gt;For example,&lt;BR /&gt;Seizure date Drug Quantity Unit County&lt;BR /&gt;12/31/2000 Marijuana 2.1 kg Something&lt;BR /&gt;12/31/2000 Marijuana 0.4 kg Something&lt;BR /&gt;12/31/2000 Marijuana 1.75 kg Something&lt;BR /&gt;&lt;BR /&gt;What I would like to have:&lt;BR /&gt;12/31/2000 Marijuana 4.25 kg Something</description>
    <pubDate>Tue, 18 Oct 2022 15:58:27 GMT</pubDate>
    <dc:creator>RebeccaB_</dc:creator>
    <dc:date>2022-10-18T15:58:27Z</dc:date>
    <item>
      <title>Aggregation of Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839217#M331832</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to aggregate a dataset. Each row of the dataset provides information on a drug seizure. I would like to combine all similar date of seizure, drug name, and county where it occurred and then use the sum function to add the quantity. There are many dates so I was wondering if could use prxmatch to search for all similar dates, drug, and county and then sum the quantity. I'm having difficulty finding an example of how to do this. Thank you in advance for any advice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Date_of_Seizure&amp;nbsp; &amp;nbsp; Drug_Name&amp;nbsp; Quantity&amp;nbsp; &amp;nbsp; &amp;nbsp;Unit&amp;nbsp; &amp;nbsp; &amp;nbsp; County&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MM/DD/YYYY&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Char&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Numeric&amp;nbsp; &amp;nbsp; &amp;nbsp; Char&amp;nbsp; &amp;nbsp; &amp;nbsp;Char&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 15:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839217#M331832</guid>
      <dc:creator>RebeccaB_</dc:creator>
      <dc:date>2022-10-18T15:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation of Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839219#M331834</link>
      <description>Dates are numeric so you can combine them based on distance. How are you defining 'similar dates'?</description>
      <pubDate>Tue, 18 Oct 2022 15:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839219#M331834</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-18T15:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation of Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839222#M331836</link>
      <description>I need to match the exact month, day, and year for the seizure date (similar dates) to the drug and then the county where it was seized.&lt;BR /&gt;&lt;BR /&gt;For example,&lt;BR /&gt;Seizure date Drug Quantity Unit County&lt;BR /&gt;12/31/2000 Marijuana 2.1 kg Something&lt;BR /&gt;12/31/2000 Marijuana 0.4 kg Something&lt;BR /&gt;12/31/2000 Marijuana 1.75 kg Something&lt;BR /&gt;&lt;BR /&gt;What I would like to have:&lt;BR /&gt;12/31/2000 Marijuana 4.25 kg Something</description>
      <pubDate>Tue, 18 Oct 2022 15:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839222#M331836</guid>
      <dc:creator>RebeccaB_</dc:creator>
      <dc:date>2022-10-18T15:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation of Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839224#M331837</link>
      <description>&lt;P&gt;Sounds like you just want to use the DATE, DRUG and COUNTY to GROUP the data.&lt;/P&gt;
&lt;P&gt;Since you have UNIT variable you should also group by that one.&amp;nbsp; You cannot really sum kilograms and pounds and ounces and grams without first converting the numbers to equivalent units.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Seizure_date :mmddyy10. Drug :$20. Quantity Unit $ County :$20. ;
  format Seizure_date yymmdd10.;
cards;
12/31/2000 Marijuana 2.1 kg Something
12/31/2000 Marijuana 0.4 kg Something
12/31/2000 Marijuana 1.75 kg Something
;

proc summary data=have nway ;
  class Seizure_date Drug Unit County;
  var Quantity;
  output out=want n=N_seizures sum=Total_Quantity ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;         Seizure_                                                                         Total_
Obs          date      Drug       Unit     County      _TYPE_    _FREQ_    N_seizures    Quantity

 1     2000-12-31    Marijuana     kg     Something      15         3           3          4.25
&lt;/PRE&gt;
&lt;P&gt;PS Avoid displaying dates in MDY or DMY order.&amp;nbsp; Either one you pick will confuse %50 of your audience.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 16:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aggregation-of-Data/m-p/839224#M331837</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-18T16:06:55Z</dc:date>
    </item>
  </channel>
</rss>

