<?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: Extract Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738849#M230530</link>
    <description>&lt;PRE&gt;data got ;
	infile cards ;
	input string $60. ;
cards;
1234567890123456789012345678901234567890
PLASMA CELLS= 0.13%  OF LEUCOCYTES.
MALIGNANT PLASMA CELLS = 0.049%
0.47%
OF WHICH =91% HAVE A NEOPLASTIC 14.2% PHENOTYPE
;
run ;

data want;
 set got;
 pid=prxparse('/[\d\.]+%/');
 s=1;e=length(string);
 call prxnext(pid,s,e,string,p,l);
 do while(p&amp;gt;0);
  want=substr(string,p,l);output;
  call prxnext(pid,s,e,string,p,l);
 end;
 drop pid s e p l;
 run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 May 2021 10:50:46 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-05-04T10:50:46Z</dc:date>
    <item>
      <title>Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738564#M230408</link>
      <description>&lt;P&gt;Good day&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to extract percentage values from the first column, i have highlighted the second column how i will like to output the values.&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="631"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="316"&gt;
&lt;P&gt;PLASMA CELLS= 0.13%&amp;nbsp; OF LEUCOCYTES.&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="316"&gt;
&lt;P&gt;0.13%&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="316"&gt;
&lt;P&gt;MALIGNANT PLASMA CELLS = 0.049%&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="316"&gt;
&lt;P&gt;0.049%&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="316"&gt;
&lt;P&gt;0.47%&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="316"&gt;
&lt;P&gt;0.47%&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="316"&gt;
&lt;P&gt;OF WHICH =91% HAVE A NEOPLASTIC PHENOTYPE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="316"&gt;
&lt;P&gt;91%&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 03 May 2021 12:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738564#M230408</guid>
      <dc:creator>Dinkepile</dc:creator>
      <dc:date>2021-05-03T12:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738570#M230411</link>
      <description>&lt;P&gt;Looks like a great job for a regular expression. Is there always only one percentage value in each string?&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 12:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738570#M230411</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-05-03T12:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738571#M230412</link>
      <description>In some theres more than one percentage but I thought if I can get this one&lt;BR /&gt;then maybe I can be able to incorporate the other.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 03 May 2021 12:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738571#M230412</guid>
      <dc:creator>Dinkepile</dc:creator>
      <dc:date>2021-05-03T12:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738576#M230416</link>
      <description>&lt;P&gt;And what do you expect as result, if there is more than one value to keep?&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 12:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738576#M230416</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-05-03T12:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738585#M230420</link>
      <description>&lt;P&gt;Go check out the documentation on &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n13as9vjfj7aokn1syvfyrpaj7z5.htm" target="_self"&gt;Perl Regular Expressions&lt;/A&gt;, then try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Set up test data */
data got ;
	infile cards ;
	input string $60. ;
cards;
1234567890123456789012345678901234567890
PLASMA CELLS= 0.13%  OF LEUCOCYTES.
MALIGNANT PLASMA CELLS = 0.049%
0.47%
OF WHICH =91% HAVE A NEOPLASTIC 14.2% PHENOTYPE
;
run ;

data want ;
	/* Create the regular expression 
	   This looks for 1 or 2 numerics, followed by a decimal point,
	   followed by 0-3 numerics and a percent sign e.g. 
       10.001%, 1.1%
	*/
	if _n_=1 then do ;
		retain regExpID ;
		regExpID=prxparse('/([0-9]{1,2}\.{0,1}[0-9]{0,3}%)/') ;
	end ;
	set got ;
	/* see if there's a match in the string*/
	position=prxmatch(regExpID,string) ;
	put position= string= ;
	/* We have a match */
	do while (position); 
		/* extract the value */
		percent=prxposn(regExpID,1,string) ;
		output ;
		put percent= ;
		next=length(percent)+position ;
		string=substr(string,next) ;
		/* see if there is another match */
		position=prxmatch(regExpID,string) ;	
		put string= ;
	end ;
run  ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 May 2021 13:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738585#M230420</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-03T13:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738787#M230503</link>
      <description>Thank you so much. The functions used above are new knowledge added. Truly appreciate</description>
      <pubDate>Tue, 04 May 2021 05:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738787#M230503</guid>
      <dc:creator>Dinkepile</dc:creator>
      <dc:date>2021-05-04T05:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738849#M230530</link>
      <description>&lt;PRE&gt;data got ;
	infile cards ;
	input string $60. ;
cards;
1234567890123456789012345678901234567890
PLASMA CELLS= 0.13%  OF LEUCOCYTES.
MALIGNANT PLASMA CELLS = 0.049%
0.47%
OF WHICH =91% HAVE A NEOPLASTIC 14.2% PHENOTYPE
;
run ;

data want;
 set got;
 pid=prxparse('/[\d\.]+%/');
 s=1;e=length(string);
 call prxnext(pid,s,e,string,p,l);
 do while(p&amp;gt;0);
  want=substr(string,p,l);output;
  call prxnext(pid,s,e,string,p,l);
 end;
 drop pid s e p l;
 run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 May 2021 10:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Data/m-p/738849#M230530</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-04T10:50:46Z</dc:date>
    </item>
  </channel>
</rss>

