<?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: Flag a new address within a sublocation group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166957#M32156</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not 100% clear what the proper sorted order is for your data.&amp;nbsp; To illustrate the solution, I'll assume it can be sorted by POL_NBR_ID, LOCATION, SUBLOCATION, and POL_EFF_DT.&amp;nbsp; Even if that's wrong, this will give you the general idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set-up&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by POL_NBR_ID location sublocation pol_eff_dt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The implementation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by pol_nbr_id location sublocation subloc_addr1 notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.subloc_addr1 then switch=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Feb 2014 15:44:40 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2014-02-07T15:44:40Z</dc:date>
    <item>
      <title>Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166956#M32155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="883"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;POL_NBR_ID&lt;/TD&gt;&lt;TD class="xl65" width="83"&gt;POL_EFF_DT&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Location&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;SubLocation&lt;/TD&gt;&lt;TD class="xl65" width="195"&gt;BUS_DESC&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;SUBLOC_ADDR1&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;SUBLOC_ADDR2&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;CITY&lt;/TD&gt;&lt;TD class="xl65" width="93"&gt;building_age&lt;/TD&gt;&lt;TD class="xl65" colspan="2" width="128"&gt;Switch&lt;BR /&gt;&amp;nbsp; Location Flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2005&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;REAL ESTATE MANAGEMENT&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;8550&amp;nbsp; Pearl&lt;/TD&gt;&lt;TD class="xl66"&gt;CHICAGO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2006&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;REAL ESTATE MANAGEMENT&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;8550&amp;nbsp; Pearl&lt;/TD&gt;&lt;TD class="xl66"&gt;CHICAGO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2007&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;OFFICE BLDG.&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;8550&amp;nbsp; Pearl&lt;/TD&gt;&lt;TD class="xl66"&gt;CHICAGO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2008&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;OFFICE BLDG.&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;8550&amp;nbsp; Pearl&lt;/TD&gt;&lt;TD class="xl66"&gt;CHICAGO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2009&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;OFFICE BLDG.&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;8550&amp;nbsp; Pearl&lt;/TD&gt;&lt;TD class="xl66"&gt;CHICAGO&lt;/TD&gt;&lt;TD align="right"&gt;39&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2010&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;OFFICE BLDG.&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;8550&amp;nbsp; Pearl&lt;/TD&gt;&lt;TD class="xl66"&gt;CHICAGO&lt;/TD&gt;&lt;TD align="right"&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2011&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;MEDICAL OFFICE BLDG.&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;2401 Asylum Way&lt;/TD&gt;&lt;TD class="xl66"&gt;GLENVIEW&lt;/TD&gt;&lt;TD align="right"&gt;10&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;06/29/2012&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD class="xl66"&gt;MEDICAL OFFICE BLDG.&lt;/TD&gt;&lt;TD class="xl66" colspan="2"&gt;2401 Asylum Way&lt;/TD&gt;&lt;TD class="xl66"&gt;GLENVIEW&lt;/TD&gt;&lt;TD align="right"&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope the formatting of the above table comes out OK.&amp;nbsp; I couldn't upload the excel file so just had to paste it in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you see above is a dataset with Policy Number, Pol. Eff. Dt, Location, Sublocation and Subloc Address 1 (amongst other less important things).&lt;/P&gt;&lt;P&gt;What I am trying to do is create SAS code to generate a 1 in the "Switch Location Flag" field above.&amp;nbsp; Notice how the flag appears when the sublocation stays the same, but there is just a change in physical address, as you can see in the Subloc Address 1 field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a pity I can't upload an Excel file here so as that the data is easily portable, but hopefully you get what I mean and can help out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 14:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166956#M32155</guid>
      <dc:creator>dal233</dc:creator>
      <dc:date>2014-02-07T14:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166957#M32156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not 100% clear what the proper sorted order is for your data.&amp;nbsp; To illustrate the solution, I'll assume it can be sorted by POL_NBR_ID, LOCATION, SUBLOCATION, and POL_EFF_DT.&amp;nbsp; Even if that's wrong, this will give you the general idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set-up&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by POL_NBR_ID location sublocation pol_eff_dt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The implementation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by pol_nbr_id location sublocation subloc_addr1 notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.subloc_addr1 then switch=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 15:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166957#M32156</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-07T15:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166958#M32157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's not quite what I want.&amp;nbsp; In that case it will not only flag the change in subloc_addr, but also the first instance of the sublocation (i.e the first "1" above).&amp;nbsp; I don't want to flag the first instance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 15:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166958#M32157</guid>
      <dc:creator>dal233</dc:creator>
      <dc:date>2014-02-07T15:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166959#M32158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, that's right.&amp;nbsp; A slight change:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if first,.subloc_addr1=1 and first.pol_nbr_id=0 then switch=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, depending on what you need, it might be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if first.subloc_addr1=1 and first.sublocation=0 then switch=1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 15:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166959#M32158</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-07T15:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166960#M32159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The sort order is Pol Nbr, Pol Eff. Dt., Location and Sublocation.&amp;nbsp; And I would like to keep it in that order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 15:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166960#M32159</guid>
      <dc:creator>dal233</dc:creator>
      <dc:date>2014-02-07T15:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166961#M32160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do believe that is it!&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 16:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166961#M32160</guid>
      <dc:creator>dal233</dc:creator>
      <dc:date>2014-02-07T16:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Flag a new address within a sublocation group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166962#M32161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should still be OK with that sorted order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort;&lt;/P&gt;&lt;P&gt;by Pol_nbr_id Pol_Eff_dt location sublocation;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The DATA step that follows would not have to change.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 16:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-a-new-address-within-a-sublocation-group/m-p/166962#M32161</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-07T16:02:42Z</dc:date>
    </item>
  </channel>
</rss>

