<?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 begins with tree alphabetic characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/738935#M230563</link>
    <description>&lt;P&gt;1. Use COUNTW() to count number of words&lt;/P&gt;
&lt;P&gt;2. Extract each word&lt;/P&gt;
&lt;P&gt;3. Check if first 3 characters are alphabetic (NOTALPHA())&lt;/P&gt;
&lt;P&gt;4. Output if valid record&lt;/P&gt;
&lt;P&gt;5. Transpose to a wide structure as desired&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length id $10 dcode $48;
	input id$ dcode$ &amp;amp;;
	datalines;
1 MCB10 PC001 AAA30
2  AC003 PA000 TAC25
3  QC000 CAB50 FCE10
;
run;

data long;
	set have;
	nwords=countw(dcode); /*1*/

	do i=1 to nwords;
		word=scan(dcode, i); /*2*/

		if not notalpha(substr(word, 1, 3)) then /*3*/
			output; /*4*/
	end;
run;

/*5*/
proc transpose data=long out=want prefix=WORD_;
	by ID;
	var word;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321775"&gt;@Chris_LK_87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset that looks like this. Each line contains an individual and codes attached to that individual. The codes are stored with spaces in one variable.&amp;nbsp;&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 PC001 AAA30 &lt;BR /&gt;2&amp;nbsp; AC003 PA000 TAC25&lt;BR /&gt;3&amp;nbsp; QC000&amp;nbsp;CAB50&amp;nbsp;FCE10&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to select every code that begins with tree alphabetic characters and place each code in a new variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;id$ dcode1$ dcode2$ dcode3$&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; MCB10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AAA30&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TAC25&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CAB50 FCE10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 May 2021 15:10:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-05-04T15:10:23Z</dc:date>
    <item>
      <title>Select codes that begins with tree alphabetic characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/738919#M230556</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset that looks like this. Each line contains an individual and codes attached to that individual. The codes are stored with spaces in one variable.&amp;nbsp;&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 PC001 AAA30 &lt;BR /&gt;2&amp;nbsp; AC003 PA000 TAC25&lt;BR /&gt;3&amp;nbsp; QC000&amp;nbsp;CAB50&amp;nbsp;FCE10&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to select every code that begins with tree alphabetic characters and place each code in a new variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;id$ dcode1$ dcode2$ dcode3$&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; MCB10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AAA30&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TAC25&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CAB50 FCE10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 14:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/738919#M230556</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-05-04T14:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that begins with tree alphabetic characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/738935#M230563</link>
      <description>&lt;P&gt;1. Use COUNTW() to count number of words&lt;/P&gt;
&lt;P&gt;2. Extract each word&lt;/P&gt;
&lt;P&gt;3. Check if first 3 characters are alphabetic (NOTALPHA())&lt;/P&gt;
&lt;P&gt;4. Output if valid record&lt;/P&gt;
&lt;P&gt;5. Transpose to a wide structure as desired&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length id $10 dcode $48;
	input id$ dcode$ &amp;amp;;
	datalines;
1 MCB10 PC001 AAA30
2  AC003 PA000 TAC25
3  QC000 CAB50 FCE10
;
run;

data long;
	set have;
	nwords=countw(dcode); /*1*/

	do i=1 to nwords;
		word=scan(dcode, i); /*2*/

		if not notalpha(substr(word, 1, 3)) then /*3*/
			output; /*4*/
	end;
run;

/*5*/
proc transpose data=long out=want prefix=WORD_;
	by ID;
	var word;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321775"&gt;@Chris_LK_87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset that looks like this. Each line contains an individual and codes attached to that individual. The codes are stored with spaces in one variable.&amp;nbsp;&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 PC001 AAA30 &lt;BR /&gt;2&amp;nbsp; AC003 PA000 TAC25&lt;BR /&gt;3&amp;nbsp; QC000&amp;nbsp;CAB50&amp;nbsp;FCE10&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to select every code that begins with tree alphabetic characters and place each code in a new variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;id$ dcode1$ dcode2$ dcode3$&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; MCB10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AAA30&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TAC25&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CAB50 FCE10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 15:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/738935#M230563</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-04T15:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select codes that begins with tree alphabetic characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/739409#M230780</link>
      <description>Thanks!</description>
      <pubDate>Thu, 06 May 2021 07:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-codes-that-begins-with-tree-alphabetic-characters/m-p/739409#M230780</guid>
      <dc:creator>Chris_LK_87</dc:creator>
      <dc:date>2021-05-06T07:26:55Z</dc:date>
    </item>
  </channel>
</rss>

