<?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: scan function. Part of third param(&amp;quot;charlist&amp;quot;) exist in first parameter. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23011#M5034</link>
    <description>Thanks!</description>
    <pubDate>Tue, 02 Nov 2010 15:16:24 GMT</pubDate>
    <dc:creator>Yuriy2301</dc:creator>
    <dc:date>2010-11-02T15:16:24Z</dc:date>
    <item>
      <title>scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23002#M5025</link>
      <description>Hi all,&lt;BR /&gt;
So I have small task: divide string into few sub-strings, using Delimiter ="]}".&lt;BR /&gt;
But there are few "]" and "}" in source string - scan function treat each of this chars as delimeter and return wrong result...&lt;BR /&gt;
Example: &lt;BR /&gt;
&lt;BR /&gt;
%macro divideIntoSepareteJsons;&lt;BR /&gt;
&lt;BR /&gt;
%let str1="typ}es": ]} "LAYO]UT":]} "Label": "LAYOUT";&lt;BR /&gt;
%let str2=%bquote(&amp;amp;str1);&lt;BR /&gt;
%let delim=%bquote(]});&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
txt="&amp;amp;str2";&lt;BR /&gt;
del="&amp;amp;delim";&lt;BR /&gt;
                firstword=scan(txt,1,del);&lt;BR /&gt;
                secword=scan(txt,2,del);&lt;BR /&gt;
                thirdword=scan(txt,3,del);&lt;BR /&gt;
                forword=scan(txt,4,del);&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%divideIntoSepareteJsons&lt;BR /&gt;
&lt;BR /&gt;
So results must be:&lt;BR /&gt;
firstword="typ}es":;&lt;BR /&gt;
secword="LAYO]UT":&lt;BR /&gt;
thirdword="Label": "LAYOUT"&lt;BR /&gt;
forword=&lt;BR /&gt;
&lt;BR /&gt;
But , becouse we have "}" in first sub-string("typ}es":) we have such result:&lt;BR /&gt;
firstword="typ &lt;BR /&gt;
secword=es":;&lt;BR /&gt;
thirdword="LAYO]UT":&lt;BR /&gt;
forword="Label": "LAYOUT"&lt;BR /&gt;
&lt;BR /&gt;
So I must somehow said SAS that I look only for whole "]}" as delimiter, not for 2 separate delimiters...&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advanced for your help...</description>
      <pubDate>Tue, 26 Oct 2010 14:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23002#M5025</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-10-26T14:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23003#M5026</link>
      <description>Pre-process the SAS variable and use the TRANWRD function to change the "delimiter word" to some unique single-character.  Then you can use the SCAN function, as needed.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 26 Oct 2010 14:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23003#M5026</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-26T14:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23004#M5027</link>
      <description>Thanks Scott,&lt;BR /&gt;
I thought about such solution before,&lt;BR /&gt;
but we can't be sure that this one unique single-character delimiter will not appear in sub-words...&lt;BR /&gt;
When we have complicated delimiter,for example [{{{] it's much more safer then use only one delimeter symbol(even if it is "~" or smth. like this)...&lt;BR /&gt;
&lt;BR /&gt;
So I look for possibility to use some complex delimiter, if it's possible at all... &lt;BR /&gt;
&lt;BR /&gt;
But, anyway, thanks!</description>
      <pubDate>Tue, 26 Oct 2010 15:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23004#M5027</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-10-26T15:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23005#M5028</link>
      <description>One more detail:&lt;BR /&gt;
We also can make some list of single delimiters, for example:&lt;BR /&gt;
~,*,^...&lt;BR /&gt;
Then we at beginning will check input string if such single delimiter exists in it.&lt;BR /&gt;
If not exists-we can use this solution with tranwrd and replacing complex delim. into single one...&lt;BR /&gt;
It looks like good variant,&lt;BR /&gt;
but even in such case we will have one additional scanning, for finding if single delimiter exist in string, and it's not very optimal:(&lt;BR /&gt;
&lt;BR /&gt;
I feel:) that must be some simpler solution, it's looks so simle task...</description>
      <pubDate>Tue, 26 Oct 2010 15:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23005#M5028</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-10-26T15:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23006#M5029</link>
      <description>Okay - suggest you use a hex-data string then, coded as a literal, like "00"X.  And you could use the INDEXC function in an assignment statement first, to detect if the character is or is not present, and then use it if not present in your data.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 26 Oct 2010 16:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23006#M5029</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-26T16:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23007#M5030</link>
      <description>Take a look at the Perl Regular Expression functions.  PRXxxxxx  They allow a great deal of flexibility (and complexity), but can be very helpful in tight corners and dark alleys.</description>
      <pubDate>Wed, 27 Oct 2010 05:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23007#M5030</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-10-27T05:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23008#M5031</link>
      <description>Thanks!</description>
      <pubDate>Wed, 27 Oct 2010 07:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23008#M5031</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-10-27T07:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23009#M5032</link>
      <description>SCAN function with Q option.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   text='"typ}es": ]} "LAYO]UT":]} "Label": "LAYOUT"';&lt;BR /&gt;
   w = countw(text,']}','Q');&lt;BR /&gt;
   do i = 1 to w;&lt;BR /&gt;
      word = scanq(text,i,']}','Q');&lt;BR /&gt;
      put 'NOTE: ' i= word=;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
NOTE: i=1 word="typ}es":&lt;BR /&gt;
NOTE: i=2 word="LAYO]UT":&lt;BR /&gt;
NOTE: i=3 word="Label": "LAYOUT"&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 27 Oct 2010 15:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23009#M5032</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-27T15:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23010#M5033</link>
      <description>The reason why data _null_'s solution is working for the test string is nothing to do with multi-character delimiters. This works because Q option ignores any delimiter characters inside quoted string; and because scan, by default, does not return (or count) 'null' words -- meaning consecutive delimiters are considered as one.&lt;BR /&gt;
&lt;BR /&gt;
See my sas-l post for a true multi-character delimiter support via a variant of coding techniques known as "_infile_ magic":&lt;BR /&gt;
&lt;A href="http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1010d&amp;amp;L=sas-l&amp;amp;D=1&amp;amp;P=26236" target="_blank"&gt;http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1010d&amp;amp;L=sas-l&amp;amp;D=1&amp;amp;P=26236&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Or toby's macro relying on call prxnext with a cleaver use of non-greedy modifier(*?) to the perl reg ex wild card character (.) at:&lt;BR /&gt;
&lt;A href="http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1010d&amp;amp;L=sas-l&amp;amp;D=1&amp;amp;O=D&amp;amp;P=27264" target="_blank"&gt;http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1010d&amp;amp;L=sas-l&amp;amp;D=1&amp;amp;O=D&amp;amp;P=27264&lt;/A&gt;</description>
      <pubDate>Thu, 28 Oct 2010 15:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23010#M5033</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-10-28T15:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23011#M5034</link>
      <description>Thanks!</description>
      <pubDate>Tue, 02 Nov 2010 15:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23011#M5034</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-11-02T15:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: scan function. Part of third param("charlist") exist in first parameter.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23012#M5035</link>
      <description>Thanks, great!</description>
      <pubDate>Tue, 02 Nov 2010 15:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-function-Part-of-third-param-quot-charlist-quot-exist-in/m-p/23012#M5035</guid>
      <dc:creator>Yuriy2301</dc:creator>
      <dc:date>2010-11-02T15:17:58Z</dc:date>
    </item>
  </channel>
</rss>

