<?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 How to retrieve the multiple instances of a word between two special characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393774#M94861</link>
    <description>&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one string and I need to extract multiple words based on two special characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ttest;
test="case when date_account_opened &amp;gt;= intnx('month',&amp;amp;STRMONTH_START.,&amp;amp;i.,'same' ) and date_account_closed &amp;lt;= intnx('month',&amp;amp;STRMONTH_END.,&amp;amp;i.,'same' ) then 1 else 0 end as Corp_New_aggregate";
inner_str = SCAN(SUBSTR(test,INDEX(test,',')+1),1,',');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, in the above example I need the output as both &amp;nbsp;STRMONTH_START and&amp;nbsp;STRMONTH_END. Now I am getting only&amp;nbsp;STRMONTH_START in the inner_str variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me to retrieve the words either in the same variable or in multiple variables as per the occurances.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2017 07:36:22 GMT</pubDate>
    <dc:creator>rajdeep</dc:creator>
    <dc:date>2017-09-07T07:36:22Z</dc:date>
    <item>
      <title>How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393774#M94861</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one string and I need to extract multiple words based on two special characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ttest;
test="case when date_account_opened &amp;gt;= intnx('month',&amp;amp;STRMONTH_START.,&amp;amp;i.,'same' ) and date_account_closed &amp;lt;= intnx('month',&amp;amp;STRMONTH_END.,&amp;amp;i.,'same' ) then 1 else 0 end as Corp_New_aggregate";
inner_str = SCAN(SUBSTR(test,INDEX(test,',')+1),1,',');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, in the above example I need the output as both &amp;nbsp;STRMONTH_START and&amp;nbsp;STRMONTH_END. Now I am getting only&amp;nbsp;STRMONTH_START in the inner_str variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me to retrieve the words either in the same variable or in multiple variables as per the occurances.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 07:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393774#M94861</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-07T07:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393792#M94866</link>
      <description>&lt;P&gt;The question seems to be connected to &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-extract-a-string-based-on-a-word-inside-the-string/m-p/391425" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-to-extract-a-string-based-on-a-word-inside-the-string/m-p/391425&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 08:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393792#M94866</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-09-07T08:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393795#M94867</link>
      <description>&lt;P&gt;Really, really not a good idea to be trying to parse code from a text string. &amp;nbsp;There are multiple possibilities which you would need to check for, upper/lower case, only first string is present, only last string, multiples unbalanced etc. I would really question why you are doing this.&amp;nbsp;Just for starters, your test string is incorrect, as the " around it will trigger the macro pre-processor to try to finid those macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393795#M94867</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-07T09:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393796#M94868</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for replying. I think earlier it was the concern of finding a piece of sentense based on 2 words and this time it's finding a word based on a keyword that is INTNX, so I raised another thread.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yeah, I had raised the thread with similar heading that could be the confusion, but the requirement is different this time I guess. I did that coding with my understading. Also, I just wanted to know can it be possible with&amp;nbsp;PRXCHANGE, finding two keywords based on a regular expression or a pettern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this will help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393796#M94868</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-07T09:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393799#M94870</link>
      <description>&lt;P&gt;Hi Rw9,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for responding. I think I had ran the same code it was working fine and giving the output as &amp;amp;STRMONTH_START. , but just wondering how to retrieve if there are multiple instances of INTNX function. I am doing this just to identify the contibuting variables inside a specific query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this much of information helps.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393799#M94870</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-07T09:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393801#M94871</link>
      <description>&lt;P&gt;Thats really the point though isn't it. &amp;nbsp;Programming allows you to code things in many different ways using a variety of techniques and constructs. &amp;nbsp;What you plan may work for one specific example, but for others it will not. &amp;nbsp;Code analysers are not simple things to create. &amp;nbsp;Take a look at this example, which uses the SAS proc scaproc (source code analyser) output to identify inputs/outputs etc. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/58/047.html" target="_blank"&gt;http://support.sas.com/kb/58/047.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Really not that straight forward.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393801#M94871</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-07T09:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393814#M94878</link>
      <description>&lt;P&gt;Thanks for replying. I think the style I am talking about to retrieve the words will be generic for any example. Anyways, will post the code if anything will click in my mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and Cheers.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 10:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393814#M94878</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-07T10:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393909#M94896</link>
      <description>&lt;P&gt;Perhaps what you need, especially if you are going to keep looking for more of these things, is a tokenizer program. This is a program that finds ALL "words" and creates an output data set that has word and the line the word was found on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you could search for "words" like "intnx" that occur more than once on the same line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data tokens;
   infile datalines dsd  ;
   length word $42.;
   input @;
   Line=_n_;
   do i= 1 to (countw(_infile_,' ,()[]{}/=;','OQST'));
      word = scan(_infile_,i,' ,()[]{}/=;');
      output;
   end;
   drop i;
   input;

datalines4;
Proc sgplot  data= internal  
        dattrmap=wicenr.ethattrmap  ;
   by agency;
   styleattrs datasymbols = (circle circlefilled );
   reg x=monoffset y=inf2Child/ 
            group=ethnicity   attrid=ethnicity
   ;         
   format  ethnicity enrethnicity. inf2Child percent7.1 monoffset monoffset.;
   yaxis values=(0 to .50 by .1) ;
   xaxis values=(0 to 60 by 6);
run ;
title;
footnote;
;;;;
run;&lt;/PRE&gt;
&lt;P&gt;If you use many long string literals&amp;nbsp;in your code you would have to increase the length of the word variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also want to consider upcase or lowcase to get consistent case for frequencies or such.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 15:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/393909#M94896</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-07T15:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the multiple instances of a word between two special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/394170#M94953</link>
      <description>&lt;P&gt;Hi Ballard,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply. I think the code given by you is tokeninzing each and every words which I don't need. Whenever the loop will be initiated it will strat the search from the begining.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried to modify your code as per mine, but I am getting the STRMONTH_START two times in output. It's not capturing the STRMONTH_END though it's identifying the total number of intnx functions used in the query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ttest;
test="case when date_account_opened &amp;gt;= intnx('month',&amp;amp;STRMONTH_START.,&amp;amp;i.,'same' ) and date_account_closed &amp;lt;= intnx('month',&amp;amp;STRMONTH_END.,&amp;amp;i.,'same' ) then 1 else 0 end as Corp_New_aggregate";
do i= 1 to (count(test,'intnx'));
      word = scan(substr(test,index(UPCASE(test),"INTNX")),2,',');
      output;
   end;
   drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Please help anyone.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 09:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-multiple-instances-of-a-word-between-two/m-p/394170#M94953</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-08T09:39:45Z</dc:date>
    </item>
  </channel>
</rss>

