<?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: re: Scan function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206377#M38351</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your list originates from a vertical (separate records) as you have illustrated, then consider using a different item separator character (one that does not appear within any item).&amp;nbsp; So if you are using PROC SQL to generate a macro-variable as your item-list, then choose a different&amp;nbsp; SEPARATED BY data-string value to distinguish items in your list, then use that data-string as your SCAN argument when parsing.&lt;/P&gt;&lt;P&gt;Scott Barry&lt;/P&gt;&lt;P&gt;SBBWorks, Inc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Jun 2015 14:59:03 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2015-06-15T14:59:03Z</dc:date>
    <item>
      <title>re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206374#M38348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi....I would like to be able to select a ID one at a time from a list. Each ID consist of 3 letters followed by a space and 4 digit number. I need to keep this ID in this form. I am assume if I used the scan function, it would consider each ID as 2 separate ID's because of the blank space in between them. Is there a way around this. Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;CME 1199&lt;/P&gt;&lt;P&gt;DLS 1213&lt;/P&gt;&lt;P&gt;WRF 1155&lt;/P&gt;&lt;P&gt;RTY 1345&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 14:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206374#M38348</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2015-06-15T14:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206375#M38349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input text &amp;amp;$ 20.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;CME 1199&lt;/P&gt;&lt;P&gt;DLS 1213&lt;/P&gt;&lt;P&gt;WRF 1155&lt;/P&gt;&lt;P&gt;RTY1345&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if prxmatch('/\w\w\w\D\S\d+/',text) then flag=1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 14:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206375#M38349</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-06-15T14:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206376#M38350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your delimited list contains items that contain the delimiter the item must mask the delimiter in some way.&amp;nbsp; Typically this is done by enclosing the item(s) that contain delimiters in quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 14:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206376#M38350</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-06-15T14:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206377#M38351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your list originates from a vertical (separate records) as you have illustrated, then consider using a different item separator character (one that does not appear within any item).&amp;nbsp; So if you are using PROC SQL to generate a macro-variable as your item-list, then choose a different&amp;nbsp; SEPARATED BY data-string value to distinguish items in your list, then use that data-string as your SCAN argument when parsing.&lt;/P&gt;&lt;P&gt;Scott Barry&lt;/P&gt;&lt;P&gt;SBBWorks, Inc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 14:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206377#M38351</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2015-06-15T14:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206378#M38352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;twildone wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi....I would like to be able to select a ID one at a time from a list. Each ID consist of 3 letters followed by a space and 4 digit number. I need to keep this ID in this form. I am assume if I used the scan function, it would consider each ID as 2 separate ID's because of the blank space in between them. Is there a way around this. Thanks,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;P&gt;CME 1199&lt;/P&gt;
&lt;P&gt;DLS 1213&lt;/P&gt;
&lt;P&gt;WRF 1155&lt;/P&gt;
&lt;P&gt;RTY 1345&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;I don't understand the reason why SCAN is suggested here. You don't need SCAN to select from the list. Could you explain further?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 15:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206378#M38352</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-06-15T15:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206379#M38353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If i understand your question properly this is how i would do it.&amp;nbsp; Im sure there are more elegant ways to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id $50.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;CME 1199 DLS 1213 WRF 1155 RTY 1345&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to countw(id) by 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sep_id = catx(' ',scan(id,i), scan(id, i+1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop id i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 15:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206379#M38353</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2015-06-15T15:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206380#M38354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...I was using the scan function as part of a macro loop to check to see whether or not the list of ID's had records contained in a larger dataset when the ID was only numerical (example, 1199) Now the ID field has changed to include 3 letters followed by a blank space and now I need to do the same check but now with the 3 letters preceeding the 4 numbers....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'Courier New'; background: white; color: navy;"&gt;PROC&lt;/STRONG&gt; &lt;STRONG style="font-family: 'Courier New'; background: white; color: navy;"&gt;SQL&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;NOPRINT&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; ID&amp;nbsp;&amp;nbsp; &lt;/SPAN&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; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;INTO&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; :IDLIST1 SEPARATED BY &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; WORK.ID_LIST;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'Courier New'; background: white; color: navy;"&gt;QUIT&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206380#M38354</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2015-06-15T16:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206381#M38355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;since you are trying to search the id which have 3 letters followed by space and 4 digits.&amp;nbsp; please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'Courier New'; background: white; color: navy;"&gt;PROC&lt;/STRONG&gt; &lt;STRONG style="font-family: 'Courier New'; background: white; color: navy;"&gt;SQL&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;NOPRINT&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; ID&amp;nbsp;&amp;nbsp; &lt;/SPAN&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; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;INTO&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; :IDLIST1 SEPARATED BY &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; WORK.ID_LIST where &lt;STRONG&gt;prxmatch('/\w\w\w\D\S\d\d\d/',text)&amp;gt;0&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'Courier New'; background: white; color: navy;"&gt;QUIT&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jag&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206381#M38355</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-06-15T16:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206382#M38356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why use macro at all?.&amp;nbsp; Just get the distinct ID list and do the test using SQL or data step.&amp;nbsp; Doing an operation on records from a SAS data set is much easier than fiddling with scan the values of a macro variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206382#M38356</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-06-15T16:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206383#M38357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are trying to handle both situations of 3 letters and no letters why not change your above code to something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT DISTINCT ID&amp;nbsp; &lt;/P&gt;&lt;P&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; INTO :IDLIST1 SEPARATED BY&lt;STRONG&gt; ','&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then use on the macro side&lt;/P&gt;&lt;P&gt;%scan(&amp;amp;idlist1, i, ',')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206383#M38357</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2015-06-15T16:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: re: Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206384#M38358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use a delimiter that is not part of the data.&amp;nbsp; For example |.&lt;/P&gt;&lt;P&gt;The third parameter to the SCAN() or %SCAN() function is the delimiter value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.... separated by '|' ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... %scan(&amp;amp;idlist,&amp;amp;i,|) ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 17:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Scan-function/m-p/206384#M38358</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-06-15T17:34:01Z</dc:date>
    </item>
  </channel>
</rss>

