<?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: Trying to compress data based on variables in different rows in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442122#M28534</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196705"&gt;@Datatician&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A lot of forum members tend to answer questions by providing actual code which is very often fully working. To do so we need some representative sample data. Your chances to get such a code based answer will increase greatly if you provide sample data in the form of a working SAS data step creating such data.&lt;/P&gt;
&lt;P&gt;We don't need a lot of data but make sure that your data is contains all the cases you want covered (so eventually amend your data to create such cases).&lt;/P&gt;
&lt;P&gt;The other thing that's appreciated: Don't just state the problem but also provide some info what you've tried already and eventually post some of your not yet fully working code. This helps us a lot to understand where you're coming from and to provide an answer suitable to your current SAS skills level.&lt;/P&gt;</description>
    <pubDate>Sun, 04 Mar 2018 02:24:00 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-03-04T02:24:00Z</dc:date>
    <item>
      <title>Trying to compress data based on variables in different rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/441934#M28519</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working with this data -&amp;nbsp;&lt;A href="https://www.kaggle.com/somesnm/partynyc" target="_blank"&gt;https://www.kaggle.com/somesnm/partynyc&lt;/A&gt; - which are essentially complaints to the police department of NYC about ongoing parties within the city in 2016. My goal is compress these complaints into actual parties (i.e., some parties were complained about more than once, so I need to separate different complaints for different locations).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is the snapshot of data sample.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In exact terms, I need to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Count Number of Complaints (id_Complaint) if:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - 2 last columns match from 1 row to another (i.e., if 2 rows have the same location, they need to be compressed into 1 row, and have count of "2")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - the filter to only count parties that have CreatedDate and ClosedDate within 12 hours of each other. This is to ensure that if complaints about the same location came during different days, I would be able to count it as different parties. Once again, requires comparisons of data in different rows in 2 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not accustomed to coding in SAS, so if you could provide instructions on how to achieve thru Query Builder, it would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 22:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/441934#M28519</guid>
      <dc:creator>Datatician</dc:creator>
      <dc:date>2018-03-02T22:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to compress data based on variables in different rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442045#M28530</link>
      <description>&lt;P&gt;I don't tend to open Office attachments from the Internet, but here are a few general suggestions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally, to compare fields between records, you need to sort on those fields. So for your grouping on complaint ID, you'd want to sort on location, and then use a data step with a "by" statement and "first." and "last." options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same for your date filter, but I don't find it completely clear what your algorithm is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 14:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442045#M28530</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-03-03T14:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to compress data based on variables in different rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442092#M28533</link>
      <description>&lt;P&gt;You do know that if you click on it, it doesn't download the file, right? It just shows you the preview...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, data looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Complaint_ID | CreatedDate | ClosedDate | Location Type | Incident Zip | City | Borough | Latitude | Longitude&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31dec15:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31DEC15:01&amp;nbsp; Store/Commer 10034&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Bronx Bronx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40.86618&amp;nbsp; -73.918930&lt;/P&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to compare records across rows, and create A row for each series of complaints that:&lt;/P&gt;&lt;P&gt;- Happened within 12 hours (ClosedDate-CreatedDAte &amp;lt;= 12 hours)&lt;/P&gt;&lt;P&gt;- Have the same location (last 2 columns are the same in different rows)&lt;/P&gt;&lt;P&gt;- Count how many complaints came for that location within that 12 hour period&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If different rows have the same location but didn't happen within one 12 hours window, it needs to create a separate row with same parameters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 20:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442092#M28533</guid>
      <dc:creator>Datatician</dc:creator>
      <dc:date>2018-03-03T20:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to compress data based on variables in different rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442122#M28534</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196705"&gt;@Datatician&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A lot of forum members tend to answer questions by providing actual code which is very often fully working. To do so we need some representative sample data. Your chances to get such a code based answer will increase greatly if you provide sample data in the form of a working SAS data step creating such data.&lt;/P&gt;
&lt;P&gt;We don't need a lot of data but make sure that your data is contains all the cases you want covered (so eventually amend your data to create such cases).&lt;/P&gt;
&lt;P&gt;The other thing that's appreciated: Don't just state the problem but also provide some info what you've tried already and eventually post some of your not yet fully working code. This helps us a lot to understand where you're coming from and to provide an answer suitable to your current SAS skills level.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Mar 2018 02:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-compress-data-based-on-variables-in-different-rows/m-p/442122#M28534</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-04T02:24:00Z</dc:date>
    </item>
  </channel>
</rss>

