<?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: need help for using CAT function and substring to fix entered data in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539831#M7131</link>
    <description>&lt;P&gt;If the parts are separated by period (and periods don't appear in the sub-parts) then use the SCAN() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* When the letter part is first ;
barcode = 'ADC.15462ds32';
L_part = scan(barcode,1,'.');
N_part = scan(barcode,2,'.');

* When the letter part is last ;
barcode = '56sdg56348.ADC';
L_part = scan(barcode,2,'.');
N_part = scan(barcode,1,'.');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can rebuild the code from the two parts.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_barcode=catx('.',L_part,N_part);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the "number" part is always longer than 3 characters and the "letter" part is always three characters then you could convert a random stream into a consistent format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if length(scan(barcode,1,'.')) &amp;gt; 3 then 
  barcode=catx('.',scan(barcode,2,'.'),scan(barcode,1,'.'))
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 02 Mar 2019 04:50:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-03-02T04:50:25Z</dc:date>
    <item>
      <title>need help for using CAT function and substring to fix entered data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539789#M7124</link>
      <description>&lt;P&gt;I'm currently working on a project where i'm trying to evaluate differences between 2 tables. The id used for both tables are barcodes but for some reason they sent it in different format. 1 has it like ADC.15462ds32 and the other has the 3 letters at the back like 56sdg56348.ADC.&amp;nbsp; &amp;nbsp;I'm trying to change it so both barcodes are in the same format so i can inner join the two tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so to do so i was wondering if using cat substr(a.barcode,last 3 digits,) but then i am not sure how to move the . and the 1st part around since the digets may be different.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539789#M7124</guid>
      <dc:creator>YukiJudai</dc:creator>
      <dc:date>2019-03-01T22:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: need help for using CAT function and substring to fix entered data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539791#M7125</link>
      <description>&lt;P&gt;You might even consider using two variables instead of 1, and joining by both BARCODE3 and BARCODE8.&amp;nbsp; But to move things around:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;barcode = catx('.', scan(barcode, 2, '.'), scan(barcode, 1, '.') );&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539791#M7125</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-01T22:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: need help for using CAT function and substring to fix entered data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539830#M7130</link>
      <description>&lt;P&gt;If the position of the period is fixed, then it is simpler to move the prefix to the end than the other way around&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;barcode2 = catx('.', substr(barcode1,5), substr(barcode1,1,3) );&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2019 03:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539830#M7130</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-02T03:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: need help for using CAT function and substring to fix entered data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539831#M7131</link>
      <description>&lt;P&gt;If the parts are separated by period (and periods don't appear in the sub-parts) then use the SCAN() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* When the letter part is first ;
barcode = 'ADC.15462ds32';
L_part = scan(barcode,1,'.');
N_part = scan(barcode,2,'.');

* When the letter part is last ;
barcode = '56sdg56348.ADC';
L_part = scan(barcode,2,'.');
N_part = scan(barcode,1,'.');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can rebuild the code from the two parts.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_barcode=catx('.',L_part,N_part);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the "number" part is always longer than 3 characters and the "letter" part is always three characters then you could convert a random stream into a consistent format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if length(scan(barcode,1,'.')) &amp;gt; 3 then 
  barcode=catx('.',scan(barcode,2,'.'),scan(barcode,1,'.'))
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Mar 2019 04:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539831#M7131</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-02T04:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: need help for using CAT function and substring to fix entered data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539918#M7147</link>
      <description>&lt;P&gt;If you don't insist on using cat-function, try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    length barcode newcode $ 20;
    
    input barcode;
    
    newcode = prxchange('s/(.+)\.(.+)/$2.$1/i', -1, trim(barcode));
    
    datalines;
ADC.15462ds32
56sdg56348.ADC
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see the very same parameters for prxchange are used, regardless of the position of the three letters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 18:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/need-help-for-using-CAT-function-and-substring-to-fix-entered/m-p/539918#M7147</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-03T18:01:06Z</dc:date>
    </item>
  </channel>
</rss>

