<?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: How to find a string prior to a special character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422687#M103932</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  string="Set Medicine; HEADACHE=24-JAN-2013; SEVERE=04-FEB-2013; MODERATE=04-DEC-2013";
pid=prxparse('/\w+(?==)/');
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 p l s e;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 20 Dec 2017 13:41:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-12-20T13:41:39Z</dc:date>
    <item>
      <title>How to find a string prior to a special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422674#M103929</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just wanted to retrieve the Word prior to the "=" sign. The below code I tried.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA T1;
LENGTH string _string str1 str2 $500;
string="Set Medicine; HEADACHE=24-JAN-2013; SEVERE=04-FEB-2013; MODERATE=04-DEC-2013";
_string=string;
Pos=0;
Curr=0;
prev=0;
 
DO WHILE (INDEX(_string,"=")&amp;gt;0);
Prev=prev+pos;
Pos=INDEX(_string,"=");
_string=SUBSTR(_string,pos+1,LENGTH(_string)-pos);
Curr=curr+pos;
END;
str1=SUBSTR(string, 1,prev-1);
str2=SCAN(string,-2,"="); 
 PUT str1 "," str2;
y=substr(string,(index(string,"=")),10);
 x=scan(substr(string,index(UPCASE(string),"=")),1,';');
/*scan(substr(sas_code2,index(UPCASE(sas_code2),"SELECT")),2,' ');*/
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me to retrieve the HEADACHE SEVERE MODERATE as an output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Rajdeep&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 12:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422674#M103929</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-12-20T12:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a string prior to a special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422682#M103931</link>
      <description>&lt;P&gt;wHYisYoUr coDE l ikE this?&amp;nbsp; Code formatting is key to anyone understanding your code, standardised casing, indentation and such like.&lt;/P&gt;
&lt;P&gt;Now from your logic, you can do (and note the code formatting and use of code window which is {i} above post area):&lt;/P&gt;
&lt;PRE&gt;data want;
  string="Set Medicine; HEADACHE=24-JAN-2013; SEVERE=04-FEB-2013; MODERATE=04-DEC-2013";
  length param result $200;
  do i=2 to countw(string,";");
    param=scan(scan(string,i,";"),1,"=");
    result=scan(scan(string,i,";"),2,"=");
    output;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Also note, you have not shown what you want to see output, so I have just guessed.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 13:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422682#M103931</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-20T13:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a string prior to a special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422687#M103932</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  string="Set Medicine; HEADACHE=24-JAN-2013; SEVERE=04-FEB-2013; MODERATE=04-DEC-2013";
pid=prxparse('/\w+(?==)/');
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 p l s e;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Dec 2017 13:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-string-prior-to-a-special-character/m-p/422687#M103932</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-20T13:41:39Z</dc:date>
    </item>
  </channel>
</rss>

