<?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: Separating a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106860#M29758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using scan function:&lt;/P&gt;&lt;P&gt;name=scan(district,1,'-');&lt;/P&gt;&lt;P&gt;number=scan(district,2,'-');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Dec 2012 22:52:34 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-12-21T22:52:34Z</dc:date>
    <item>
      <title>Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106858#M29756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a data variable that appears to have been merged with two different variables.&amp;nbsp; I now need to separate the variable into two new variables. Is there a way to pull apart a variable to create two different new variables.&amp;nbsp;&amp;nbsp; The position location is never the same so I dont believe I can use the substring function.&amp;nbsp; Here is sample:&lt;/P&gt;&lt;P&gt;Data element is District and it appears to have been combined with the district name and a number.&amp;nbsp; I need to separate the name and number-&amp;nbsp; Is it possible? &lt;/P&gt;&lt;P&gt;'Alliance College-Ready Academy - 0165866'&lt;/P&gt;&lt;P&gt;'Excel Prep Charter - 018842'&lt;/P&gt;&lt;P&gt;'Fortuna Elementary - 038521'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 22:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106858#M29756</guid>
      <dc:creator>SannaSanna</dc:creator>
      <dc:date>2012-12-21T22:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106859#M29757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;irsIn a data step try:&lt;/P&gt;&lt;P&gt;WARNING: Assumes - is in every value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pos = index(district,' - ');&lt;/P&gt;&lt;P&gt;DistrictName = substr(district,1,(pos-1));&lt;/P&gt;&lt;P&gt;DistrictNumber = substr(district,(pos+3));&lt;/P&gt;&lt;P&gt;Drop pos; /* may leave in POS while doing diagnostics */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll need to set the lengths of DistrictName and DistrictNumber to desired else they're likely to get truncated.&lt;/P&gt;&lt;P&gt;You may need pos-2 or pos+2 depending on whether there are more spaces around the hyphen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have many examples with the hyphen in name as well this may get sticky trying to find the right one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Edward Ballard because initial search for single hyphen failed on example first data example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 22:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106859#M29757</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-12-21T22:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106860#M29758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using scan function:&lt;/P&gt;&lt;P&gt;name=scan(district,1,'-');&lt;/P&gt;&lt;P&gt;number=scan(district,2,'-');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 22:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106860#M29758</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-12-21T22:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106861#M29759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome!&amp;nbsp; Thank you this worked beautiflly!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 22:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106861#M29759</guid>
      <dc:creator>SannaSanna</dc:creator>
      <dc:date>2012-12-21T22:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106862#M29760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the results for&lt;/P&gt;&lt;P&gt;'Alliance College-Ready Academy - 0165866'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The inital responses may yield&lt;/P&gt;&lt;P&gt;name = Alliance College&lt;/P&gt;&lt;P&gt;number= Ready Academy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 22:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106862#M29760</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-12-21T22:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106863#M29761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suzanne: You might find call scan helpful.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input district &amp;amp; $255.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;Alliance College-Ready Academy - 0165866&lt;/P&gt;&lt;P&gt;Excel Prep Charter - 018842&lt;/P&gt;&lt;P&gt;Fortuna Elementary - 038521&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; CALL SCAN(district, -1, _pos, _len );&lt;/P&gt;&lt;P&gt;&amp;nbsp; name=substr(district,1,_pos-3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; number=substr(district,_pos);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 23:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106863#M29761</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-12-21T23:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Separating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106864#M29762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much Mr. Tabachneck!!&amp;nbsp;&amp;nbsp; That resolved it and much thanks to ballardw for bringing that to my attention. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 23:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Separating-a-variable/m-p/106864#M29762</guid>
      <dc:creator>SannaSanna</dc:creator>
      <dc:date>2012-12-21T23:41:41Z</dc:date>
    </item>
  </channel>
</rss>

