<?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: break field with - in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626102#M184617</link>
    <description>&lt;P&gt;It is great.&lt;/P&gt;
&lt;P&gt;Now i want to understand please:&lt;/P&gt;
&lt;P&gt;1-Why this statements didn't work&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Branch_id &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;200&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2-&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;    branch &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Branch_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;     &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Branch_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the meaning of numbers "1"&amp;nbsp; and "2" in scan function?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2020 11:34:34 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-02-20T11:34:34Z</dc:date>
    <item>
      <title>break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626064#M184595</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have 2 questions please:&lt;/P&gt;
&lt;P&gt;1- I create a data set and I get only 4 rows but in the data set there are 8 rows&lt;/P&gt;
&lt;P&gt;2-I want to create new 2 fields:&lt;/P&gt;
&lt;P&gt;branch -take the digits in left side of&amp;nbsp;/ symbol&amp;nbsp; in&amp;nbsp;Branch_id field&lt;/P&gt;
&lt;P&gt;ID-Take the digits in right side of&amp;nbsp;/&amp;nbsp;symbol in&amp;nbsp;Branch_id field&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data example;
input Branch_id $200.;
cards;
727 - 6920351
616 - 4312710
851 - 37366723
641 - 2053927
921 - 8592059
891 - 6794396
932 - 44851042
22-99999999
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 07:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626064#M184595</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-20T07:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626066#M184597</link>
      <description>&lt;P&gt;&lt;STRONG&gt;1)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data example;
input Branch_id $ 1-15;
cards;
727 - 6920351
616 - 4312710
851 - 37366723
641 - 2053927
921 - 8592059
891 - 6794396
932 - 44851042
22-99999999
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;2)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set example;
    branch = scan(Branch_id, 1, '-');
    id     = scan(Branch_id, 2, '-');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 07:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626066#M184597</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-20T07:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626072#M184601</link>
      <description>&lt;P&gt;Datalines are by definition padded to 80 characters; reading with a $200. format causes a skip to the next input line (you can see this in the log - Maxim 2!).&lt;/P&gt;
&lt;P&gt;Use the truncover option to read with an overlong format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data example;
infile cards truncover;
input Branch_id $200.;
cards;
727 - 6920351
616 - 4312710
851 - 37366723
641 - 2053927
921 - 8592059
891 - 6794396
932 - 44851042
22-99999999
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For breaking up a string with a delimiter, use the scan() function.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 08:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626072#M184601</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-20T08:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626077#M184603</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data example;
infile cards dlm='-';
input Branch id;
cards;
727 - 6920351
616 - 4312710
851 - 37366723
641 - 2053927
921 - 8592059
891 - 6794396
932 - 44851042
22-99999999
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 08:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626077#M184603</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-02-20T08:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626102#M184617</link>
      <description>&lt;P&gt;It is great.&lt;/P&gt;
&lt;P&gt;Now i want to understand please:&lt;/P&gt;
&lt;P&gt;1-Why this statements didn't work&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Branch_id &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;200&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2-&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;    branch &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Branch_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;     &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Branch_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the meaning of numbers "1"&amp;nbsp; and "2" in scan function?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 11:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626102#M184617</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-20T11:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626105#M184619</link>
      <description>&lt;P&gt;1) See&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;s answer below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) I treat - as a delimiter in the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0jshdjy2z9zdzn1h7k90u99lyq6.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;Scan Function&lt;/A&gt;&amp;nbsp;and take the first (1) word and assign it to branch and the second word (2) and assign it to id.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 11:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626105#M184619</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-20T11:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: break field with -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626106#M184620</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It is great.&lt;/P&gt;
&lt;P&gt;Now i want to understand please:&lt;/P&gt;
&lt;P&gt;1-Why this statements didn't work&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Branch_id &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;200&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;2-&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;    branch &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Branch_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;     &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Branch_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;What is the meaning of numbers "1"&amp;nbsp; and "2" in scan function?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Regarding your question 2:&lt;/P&gt;
&lt;P&gt;Maxim 1: Read the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jshdjy2z9zdzn1h7k90u99lyq6.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Documentation&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;count&lt;/EM&gt;&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;is a nonzero numeric constant, variable, or expression that has an integer value. The integer value specifies the number of the word in the character string that you want SCAN to select. For example, a value of 1 indicates the first word, a value of 2 indicates the second word, and so on. The following rules apply:&lt;/P&gt;
&lt;UL class="xisDoc-listUnordered"&gt;
&lt;LI class="xisDoc-item"&gt;If&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;count&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is positive, SCAN counts words from left to right in the character string.&lt;/LI&gt;
&lt;LI class="xisDoc-item"&gt;If&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;count&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is negative, SCAN counts words from right to left in the character string.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 11:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/break-field-with/m-p/626106#M184620</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-20T11:45:08Z</dc:date>
    </item>
  </channel>
</rss>

