<?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: Select codes that starts with two letters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780843#M248843</link>
    <description>&lt;P&gt;If we for example think that each code is stored in separate variables, example:&lt;/P&gt;
&lt;P&gt;dcode1 dcode2 dcode3 dcode4 dcode5 etc. Then I could use an array.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Nov 2021 19:32:35 GMT</pubDate>
    <dc:creator>Chris_LK_87</dc:creator>
    <dc:date>2021-11-17T19:32:35Z</dc:date>
    <item>
      <title>Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780816#M248822</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My dataset looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;length id $10 dcode $48;&lt;BR /&gt;input id$ dcode$ &amp;amp;;&lt;BR /&gt;datalines;&lt;BR /&gt;1 MCB10 PCF01 AAA30&lt;BR /&gt;2 AC003 PL000 TAC25&lt;BR /&gt;3 QC000 CAB50 FCE10&lt;BR /&gt;4 MA100 CA500 DE100&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would&amp;nbsp; like to flag (1 or 0) every row if they have a code that starts with two letters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;length id $10 dcode $48;&lt;BR /&gt;input id$ dcode$ &amp;amp; $let_flag;&lt;BR /&gt;datalines;&lt;BR /&gt;1 MCB10 PCF01 AAA30 0&lt;BR /&gt;2 AC003 PL000 TAC25 1&lt;BR /&gt;3 QC000 CAB50 FCE10 1&lt;BR /&gt;4 MA100 CA500 DE100 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 18:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780816#M248822</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-11-17T18:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780825#M248830</link>
      <description>&lt;P&gt;So, you have multiple codes in your Dcode Variable, right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do all of them have to start with exactly 2 letters or at least 2 letters?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why is let_flag = 0 in the first obs?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 18:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780825#M248830</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-17T18:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780827#M248831</link>
      <description>&lt;P&gt;"I would like to flag (1 or 0) every row if they have a code that starts with two letters."&lt;/P&gt;
&lt;P&gt;Define "a code". As I look at your data you apparently have 3 values stuck into a single variable. In a very large number of cases this is very poor data structuring so I can't tell if you want the "starts with two letters" to mean the long value with multiple spaces as a single code or each of the pieces separated by spaces to be a code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Exactly 2?&amp;nbsp; Of ALL the groups or just any one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 18:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780827#M248831</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-17T18:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780841#M248841</link>
      <description>&lt;P&gt;Yes, the codes are stored in one variable. The codes always contain five digits, they can start with two letters or three letters. I would like to select the codes that starts with two letters.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 19:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780841#M248841</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-11-17T19:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780843#M248843</link>
      <description>&lt;P&gt;If we for example think that each code is stored in separate variables, example:&lt;/P&gt;
&lt;P&gt;dcode1 dcode2 dcode3 dcode4 dcode5 etc. Then I could use an array.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 19:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780843#M248843</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-11-17T19:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780844#M248844</link>
      <description>They should start with exatcly two letters. The first obs has let_flag=0 because neither of the codes in the first row starts exactly two letters.</description>
      <pubDate>Wed, 17 Nov 2021 19:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780844#M248844</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-11-17T19:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780845#M248845</link>
      <description>&lt;P&gt;Comment to post. It should be start with exactly two letters.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 19:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780845#M248845</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-11-17T19:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780863#M248854</link>
      <description>&lt;P&gt;If I'm understanding you, you want flag=1 if&amp;nbsp;&lt;STRONG&gt;any&lt;/STRONG&gt; of the codes on the record start with exactly 2 letters (followed by numeric digits). This regular expression checks for that match (and whether it occurs at the start of a record or after a space).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data have;
length id $10 dcode $48;
input id$ dcode$ &amp;amp;;
datalines;
1 MCB10 PCF01 AAA30
2 AC003 PL000 TAC25
3 QC000 CAB50 FCE10
4 MA100 CA500 DE100
;
run;
data want;
 set have;
 flag = (prxmatch('/(^|\s)[A-Z][A-Z][0-9]/',dcode)&amp;gt;0);
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 20:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780863#M248854</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-11-17T20:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that starts with two letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780963#M248881</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;FLAG= (prxmatch('/[A-Z][A-Z][^A-Z]/',DCODE)=1);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 08:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-starts-with-two-letters/m-p/780963#M248881</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-18T08:28:12Z</dc:date>
    </item>
  </channel>
</rss>

