<?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 to extract data from string with conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466669#M119096</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;SOme of the data field has so by using the code i can get the first string but second one fails i.e it gives from the start not from "The rate"&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; HAVE&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;length&lt;/SPAN&gt; string &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;256&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo 1&amp;nbsp; then... set datapoint value for The rate in Criteria to has previously been enrolled in this., and execute the "Return True" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo Exclusion 15 then... set datapoint value for in Criteria to The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-SSRS:&lt;BR /&gt;- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR&lt;BR /&gt;- “Yes” to any question on the section within the last 3 months , OR&lt;BR /&gt;- “Yes” to questions 4 or 5 on the on the section&lt;BR /&gt;, and execute the "Return True" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;so in second string if i do not have "." then i need it till end&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then explain us the logic you need to create the desired result AND &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;show us the desired result based on the sample data posted&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 May 2018 23:01:29 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-05-31T23:01:29Z</dc:date>
    <item>
      <title>Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466061#M118888</link>
      <description>&lt;P&gt;I have a variable with data and want to extract perticular data which starts with "The rate" and ends with "." but some data doesnt have "." and then in those cases it should extract till the end. I am not sure how to use that condition. Any help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data is like the below&lt;/P&gt;
&lt;P&gt;inflix="If IEE 22 then... set datapoint value for IETEST to The rate has or has had one or more of the following conditions that:- neurological disorder";&lt;BR /&gt; inflix2="If IEE 12 then... set datapoint value for LIME to The rate has or has had one or more of the following condition has not been seen. this is what is not expected";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first case has no fullstop and second one has and only want data till not been seen..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the below step&lt;/P&gt;
&lt;P&gt;IETEST=substr(infix,index(infix,"The patient"),index(substr(infix,index(infix,"The rate")),'.'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help how to make a condition that if it has "." then end the extraction else take the rest from The rate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 14:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466061#M118888</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-05-30T14:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466276#M118952</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  PRX=prxparse('s/.*(The rate .*?(\.|$)).*/$1/o');
  IN1="If IEE 12 then... set datapoint value for LIME to The rate has or has had one or more of the following condition has not been seen. this is what is not expected"; 
  IN2="If IEE 22 then... set datapoint value for IETEST to The rate has or has had one or more of the following conditions that:- neurological disorder";
  OUT1=prxchange(PRX,1,IN1); put OUT1=;
  OUT2=prxchange(PRX,1,IN2); put OUT2=;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;OUT1=The rate has or has had one or more of the following condition has not been seen.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;OUT2=The rate has or has had one or more of the following conditions that:- neurological disorder&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The regular expression reads as:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&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; &amp;nbsp; &amp;nbsp;substitution requested&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;/&lt;/STRONG&gt;&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; &amp;nbsp; &amp;nbsp; start of match pattern&lt;/P&gt;
&lt;P&gt;.*&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; &amp;nbsp; &amp;nbsp; any number of characters&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;(The rate .*?(\.|$))&lt;/STRONG&gt;&amp;nbsp; then a&amp;nbsp;group made of: &lt;EM&gt;The rate&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&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; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; then space&lt;SPAN&gt;&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; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;.*?&amp;nbsp;&lt;/STRONG&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;any number of characters&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;(but don't try to match all of them)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;(\.|$)&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; then&amp;nbsp;either a dot or the end of the&amp;nbsp;string&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;.*&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp; any number of characters&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;/&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;end of match pattern, start of replace pattern&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;$1&lt;/STRONG&gt;&amp;nbsp;replace match with first group&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;/&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;end of replace pattern&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;o&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;only compile once&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regular expressions look complex but are worth learning when handling strings, as they they are so powerful&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 22:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466276#M118952</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-30T22:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466333#M118978</link>
      <description>&lt;P&gt;My data for both are in one variable so i need to have condition which needs to check if it has "." then end or else continue till end&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 06:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466333#M118978</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-05-31T06:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466336#M118980</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;My data for both are in one variable so i need to have condition which needs to check if it has "." then end or else continue till end&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Isn't this exactly what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;'s code does using your sample data? If not then&amp;nbsp;please show us how the desired result using your sample data should look like.&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 06:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466336#M118980</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-31T06:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466390#M118997</link>
      <description>&lt;P&gt;It doesnt work if i have special characters like below in the string&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; IsEqualTo Exclusion 15 then... set datapoint value for IETEST in Exclusion is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-S:&lt;BR /&gt;- ”Yes” to questions 4 or 5 on the&amp;nbsp; section within the last 3 months, OR&lt;BR /&gt;- “Yes” to any question on the&amp;nbsp; section within the last 3 months , OR&lt;BR /&gt;- “Yes” to questions 4 or 5 on the on the&amp;nbsp; section at Base&lt;BR /&gt;, and execute the "Return True" custom function&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 10:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466390#M118997</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-05-31T10:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466394#M118998</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;To avoid a lot of back and forth what would really help is if you would provide us with some sample data (in the form of a SAS data step).&lt;/P&gt;
&lt;P&gt;Try to create some data which contains all the challenges/variations to be solved but keep the data also to the minimum required.&lt;/P&gt;
&lt;P&gt;Something like below as a starting point - just expand on it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  length string @256;
  string="AA BB... word1 word2. word3"; output;
  string="&lt;SPAN&gt;AA BB... word1 word2&lt;/SPAN&gt; &lt;SPAN&gt;word3&lt;/SPAN&gt;"; output;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then explain us the logic you need to create the desired result AND show us the desired result based on the sample data posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 11:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466394#M118998</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-31T11:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466470#M119024</link>
      <description>&lt;P&gt;SOme of the data field has so by using the code i can get the first string but second one fails i.e it gives from the start not from "The rate"&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; HAVE&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;length&lt;/SPAN&gt; string &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;256&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo 1&amp;nbsp; then... set datapoint value for The rate in Criteria to has previously been enrolled in this., and execute the "Return True" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo Exclusion 15 then... set datapoint value for in Criteria to The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-SSRS:&lt;BR /&gt;- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR&lt;BR /&gt;- “Yes” to any question on the section within the last 3 months , OR&lt;BR /&gt;- “Yes” to questions 4 or 5 on the on the section&lt;BR /&gt;, and execute the "Return True" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;so in second string if i do not have "." then i need it till end&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 14:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466470#M119024</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-05-31T14:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466645#M119085</link>
      <description>&lt;P&gt;No toot sure why you say it's failing. It's working as expected here.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  length OUT1 OUT2 $800;
  PRX=prxparse('s/.*(The rate .*?(\.|$)).*/$1/o');
  IN1='If IE in Criteria IsEqualTo Exclusion 15 then... set datapoint value for in Criteria to The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-SSRS:- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR- “Yes” to any question on the section within the last 3 months , OR- “Yes” to questions 4 or 5 on the on the section, and execute the "Return True" custom function'; 
  IN2='If IE in Criteria IsEqualTo 1  then... set datapoint value for The rate in Criteria to has previously been enrolled in this., and execute the "Return True" custom function'; 
  OUT1=prxchange(PRX,1,IN1); put OUT1=;
  OUT2=prxchange(PRX,1,IN2); put OUT2=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1 2 3 4 5 6 7"&gt;OUT1=The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="1 2 3 4 5 6 7"&gt; or who answers on the C-SSRS:- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR- “Yes” to any&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="1 2 3 4 5 6 7"&gt; question on the section within the last 3 months , OR- “Yes” to questions 4 or 5 on the on the section, and execute&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="1 2 3 4 5 6 7"&gt; the "Return True" custom function&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="1 2 3 4 5 6 7"&gt;OUT2=The rate in Criteria to has previously been enrolled in this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 21:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466645#M119085</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-31T21:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466669#M119096</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;SOme of the data field has so by using the code i can get the first string but second one fails i.e it gives from the start not from "The rate"&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; HAVE&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;length&lt;/SPAN&gt; string &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;256&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo 1&amp;nbsp; then... set datapoint value for The rate in Criteria to has previously been enrolled in this., and execute the "Return True" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo Exclusion 15 then... set datapoint value for in Criteria to The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-SSRS:&lt;BR /&gt;- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR&lt;BR /&gt;- “Yes” to any question on the section within the last 3 months , OR&lt;BR /&gt;- “Yes” to questions 4 or 5 on the on the section&lt;BR /&gt;, and execute the "Return True" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;so in second string if i do not have "." then i need it till end&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then explain us the logic you need to create the desired result AND &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;show us the desired result based on the sample data posted&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 23:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466669#M119096</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-31T23:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466751#M119143</link>
      <description>&lt;P&gt;sorry for not being clear.&lt;/P&gt;
&lt;P&gt;In this data&lt;/P&gt;
&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; HAVE&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;length&lt;/SPAN&gt; string &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;256&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo 1  then... set datapoint value for The rate in Criteria to has previously been enrolled in this., and execute the "&lt;/SPAN&gt;Return True&lt;SPAN class="token string"&gt;" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  string&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"If IE in Criteria IsEqualTo Exclusion 15 then... set datapoint value for in Criteria to The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-SSRS:- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR- “Yes” to any question on the section within the last 3 months , OR- “Yes” to questions 4 or 5 on the on the section, and execute the "&lt;/SPAN&gt;Return True&lt;SPAN class="token string"&gt;" custom function"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;string1=”The rate in Criteria to has previously been enrolled in this.”&lt;/P&gt;
&lt;P&gt;String2=”The rate is at significant risk of harming himself/herself or others according to the investigator’s judgement, or who answers on the C-SSRS:- ”Yes” to questions 4 or 5 on the section within the last 3 months , OR- “Yes” to any question on the section within the last 3 months , OR- “Yes” to questions 4 or 5 on the on the section”&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so in string2 there is no "." so i need to end with before ", and execute "&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 06:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/466751#M119143</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-06-01T06:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data from string with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/467063#M119207</link>
      <description>&lt;P&gt;If you start adding such variations, you are better off with something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  STARTPOS = find(STR, 'The rate');
  ENDPOS1  = find(STR, '.', STARTPOS);
  ENDPOS2  = find(STR, ', and execute ', STARTPOS) -1 ;
  NEWSTR   = substr(STR, STARTPOS, min(ENDPOS1, ENDPOS2, length(STR)) - STARTPOS);  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please alter to suit.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jun 2018 01:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-from-string-with-conditions/m-p/467063#M119207</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-06-02T01:53:35Z</dc:date>
    </item>
  </channel>
</rss>

