<?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: Character String Extract Help - Enterprise Guide in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627153#M20493</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168338"&gt;@maliksmom2000&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is another approach to achieve this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input text $200.;
datalines;
Valve, SQUARE, CAST IRON, 3 IN, THD, BLACK, MSP 54-37, FITTING
Pipe, SQUARE HEAD, 3 IN, THD, 175 PSIG, BLACK, MSP54-37, FITTING
PLUG, SQUARE HEAD, CAST IRON, 3 IN, THD, 175 PSIG, BLACK, MSP 54-37.1, FITTING
PLUG, SQUARE HEAD, CAST IRON, 3 IN, STEEL, THD, 175 PSIG, BLACK, MSP 54-37.1, MSP 11-1.1, FITTING
;

proc sql noprint;
	select max(countw(text,',')), max(count(text,"MSP")) into:nb1,:nb2 from have;
quit;

data want;
	set have;
	array _MSP (&amp;amp;nb1) $ 200;
	array MSP (&amp;amp;nb2) $ 20;
	do i=1 to countw(text,',');
		if prxmatch('/MSP\s*\d+-*\d+\.*\d*/',scan(text,i,',')) then _MSP(i) = scan(text,i,',');
	end;
	MSP_extract = catx(',',of _MSP(*));
	do j=1 to count(text,"MSP");
		MSP(j) = scan(MSP_extract,j,',');
	end;
	drop i j MSP_extract _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture d’écran 2020-02-25 à 12.01.59.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36387i8C075AB9057305A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-02-25 à 12.01.59.png" alt="Capture d’écran 2020-02-25 à 12.01.59.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Feb 2020 11:02:29 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-02-25T11:02:29Z</dc:date>
    <item>
      <title>Character String Extract Help - Enterprise Guide</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627053#M20482</link>
      <description>&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;I am trying to extract a specific word from a character string, and it may be written differently.&amp;nbsp; Everything I need to extract contains or starts with "MSP" I need not only the work MSP but also the numbers following (there's over 100 number combinations and I do not have a master list):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;Examples of text:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;Valve, SQUARE, CAST IRON, 3 IN, THD, BLACK, MSP 54-37, FITTING (need to return "MSP 54-37)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; word-spacing: 0px; cursor: text; orphans: 2; float: none; -webkit-text-stroke-width: 0px;"&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;Pipe, SQUARE HEAD, 3 IN, THD, 175 PSIG, BLACK, MSP54-37, FITTING (need to return "MSP 54-37)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; word-spacing: 0px; cursor: text; orphans: 2; float: none; -webkit-text-stroke-width: 0px;"&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;PLUG, SQUARE HEAD, CAST IRON, 3 IN, THD, 175 PSIG, BLACK, MSP 54-37.1, FITTING (need to return "MSP 54-37.1)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; word-spacing: 0px; cursor: text; orphans: 2; float: none; -webkit-text-stroke-width: 0px;"&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;PLUG, SQUARE HEAD, CAST IRON, 3 IN, STEEL, THD, 175 PSIG, BLACK, MSP 54-37.1, MSP 11-1.1, FITTING (need to return "MSP 54-37.1 &amp;amp; MSP 11-1.1 in separate columns)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;does anyone know how to do this?&amp;nbsp; I am using Enterprise Guide but I know I can cut &amp;amp; paste code directly into the window as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; font-family: '&amp;amp;quot',serif; font-size: 10.5pt;"&gt;Thank you!!!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 22:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627053#M20482</guid>
      <dc:creator>maliksmom2000</dc:creator>
      <dc:date>2020-02-24T22:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Character String Extract Help - Enterprise Guide</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627055#M20483</link>
      <description>&lt;P&gt;I need to understand your input data better.&amp;nbsp; Show it in the form of a data step using CARDS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, show what you WANT.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 22:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627055#M20483</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-02-24T22:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Character String Extract Help - Enterprise Guide</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627058#M20484</link>
      <description>&lt;P&gt;Test this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input line $200.;
datalines;
Valve, SQUARE, CAST IRON, 3 IN, THD, BLACK, MSP 54-37, FITTING
Pipe, SQUARE HEAD, 3 IN, THD, 175 PSIG, BLACK, MSP54-37, FITTING
PLUG, SQUARE HEAD, CAST IRON, 3 IN, THD, 175 PSIG, BLACK, MSP 54-37.1, FITTING
PLUG, SQUARE HEAD, CAST IRON, 3 IN, STEEL, THD, 175 PSIG, BLACK, MSP 54-37.1, MSP 11-1.1, FITTING
;

data want;
if not prxID then prxID + prxparse("/\b(\w*MSP\w*)\s*([-.0-9 ]+)/i");
set have;
length found $20;
start = 1;
stop = length(line);
call prxnext(prxID, start, stop, line, position, length);
do while (position &amp;gt; 0);
   found = catx(" ", prxposn(prxId, 1, line), prxposn(prxId, 2, line));
   output;
   call prxnext(prxID, start, stop, line, position, length);
   end;
drop prxID start stop position length;
run;

proc print data=want noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;line 	found
Valve, SQUARE, CAST IRON, 3 IN, THD, BLACK, MSP 54-37, FITTING 	MSP 54-37
Pipe, SQUARE HEAD, 3 IN, THD, 175 PSIG, BLACK, MSP54-37, FITTING 	MSP54 -37
PLUG, SQUARE HEAD, CAST IRON, 3 IN, THD, 175 PSIG, BLACK, MSP 54-37.1, FITTING 	MSP 54-37.1
PLUG, SQUARE HEAD, CAST IRON, 3 IN, STEEL, THD, 175 PSIG, BLACK, MSP 54-37.1, MSP 11-1.1, FITTING 	MSP 54-37.1
PLUG, SQUARE HEAD, CAST IRON, 3 IN, STEEL, THD, 175 PSIG, BLACK, MSP 54-37.1, MSP 11-1.1, FITTING 	MSP 11-1.1&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Feb 2020 23:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627058#M20484</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-02-24T23:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Character String Extract Help - Enterprise Guide</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627153#M20493</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168338"&gt;@maliksmom2000&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is another approach to achieve this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input text $200.;
datalines;
Valve, SQUARE, CAST IRON, 3 IN, THD, BLACK, MSP 54-37, FITTING
Pipe, SQUARE HEAD, 3 IN, THD, 175 PSIG, BLACK, MSP54-37, FITTING
PLUG, SQUARE HEAD, CAST IRON, 3 IN, THD, 175 PSIG, BLACK, MSP 54-37.1, FITTING
PLUG, SQUARE HEAD, CAST IRON, 3 IN, STEEL, THD, 175 PSIG, BLACK, MSP 54-37.1, MSP 11-1.1, FITTING
;

proc sql noprint;
	select max(countw(text,',')), max(count(text,"MSP")) into:nb1,:nb2 from have;
quit;

data want;
	set have;
	array _MSP (&amp;amp;nb1) $ 200;
	array MSP (&amp;amp;nb2) $ 20;
	do i=1 to countw(text,',');
		if prxmatch('/MSP\s*\d+-*\d+\.*\d*/',scan(text,i,',')) then _MSP(i) = scan(text,i,',');
	end;
	MSP_extract = catx(',',of _MSP(*));
	do j=1 to count(text,"MSP");
		MSP(j) = scan(MSP_extract,j,',');
	end;
	drop i j MSP_extract _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture d’écran 2020-02-25 à 12.01.59.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36387i8C075AB9057305A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-02-25 à 12.01.59.png" alt="Capture d’écran 2020-02-25 à 12.01.59.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 11:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627153#M20493</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-25T11:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Character String Extract Help - Enterprise Guide</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627704#M20571</link>
      <description>&lt;P&gt;Thank you so much!!!!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 22:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Character-String-Extract-Help-Enterprise-Guide/m-p/627704#M20571</guid>
      <dc:creator>maliksmom2000</dc:creator>
      <dc:date>2020-02-26T22:47:04Z</dc:date>
    </item>
  </channel>
</rss>

