<?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: Split field into 2 field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613852#M179344</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way is to use 'DLM'. Here is it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl;
infile datalines dlm = '-';
input Customer Branch ;
datalines;
2345777-783
3444-965
476-814
47474744-981
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Dec 2019 05:30:49 GMT</pubDate>
    <dc:creator>KachiM</dc:creator>
    <dc:date>2019-12-26T05:30:49Z</dc:date>
    <item>
      <title>Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613849#M179341</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to split&amp;nbsp; field "Customer_Branch"&amp;nbsp; into two fields: "Customer"&amp;nbsp; and "branch".&lt;/P&gt;
&lt;P&gt;All digits left to minus sign will be in "Customer" field&lt;/P&gt;
&lt;P&gt;All digits right&amp;nbsp; to minus sign will be in "branch" field.&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl;
input Customer_Branch $30.;
cards;
2345777-783
3444-965
476-814
47474744-981
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 04:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613849#M179341</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-26T04:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613850#M179342</link>
      <description>&lt;P&gt;I found nice solution.&lt;/P&gt;
&lt;P&gt;Is there another nice way to do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl;
input Customer_Branch $30.;
cards;
2345777-783
3444-965
476-814
47474744-981
;
run;
data tbl2;
set tbl;
Customer=substr(Customer_Branch, 1, find(Customer_Branch, '-')-1);
Branch=substr(Customer_Branch, length(Customer)+2, length(Customer_Branch)-length(Customer)-1);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 05:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613850#M179342</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-26T05:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613852#M179344</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way is to use 'DLM'. Here is it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl;
infile datalines dlm = '-';
input Customer Branch ;
datalines;
2345777-783
3444-965
476-814
47474744-981
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 05:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613852#M179344</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-12-26T05:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613856#M179347</link>
      <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl;
input Customer_Branch $30.;
cards;
2345777-783
3444-965
476-814
47474744-981
;
run;
data tbl2;
set tbl;
Customer=scan(Customer_Branch, 1, '-');
Branch=scan(Customer_Branch, 2, '-');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 06:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613856#M179347</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-12-26T06:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613864#M179352</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set tbl;
Customer=substr(Customer_Branch,1,find(Customer_Branch,'-')-1);
Branch=substr(Customer_Branch,find(Customer_Branch,'-')+1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 08:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613864#M179352</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2019-12-26T08:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613866#M179354</link>
      <description>&lt;P&gt;This is the classic case for the scan() function, see &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;KISS (Maxim 29)&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 09:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613866#M179354</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-26T09:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Split field into 2 field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613873#M179358</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the scan function, which is the easiest way to do this job in your case.&lt;/P&gt;
&lt;P&gt;It splits your string in several parts ("words") according to a delimiter that you specify as the third argument (in your case, an hyphen)&lt;/P&gt;
&lt;P&gt;You can then retrieve the first, the second, ... word.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl2;
	set tbl;
	Customer = scan(Customer_Branch,1,"-");
	Branch = scan(Customer_Branch,2,"-");
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Dec 2019 10:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-field-into-2-field/m-p/613873#M179358</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-26T10:27:00Z</dc:date>
    </item>
  </channel>
</rss>

