<?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 do I scan a 32K field and extract names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322856#M71484</link>
    <description>&lt;P&gt;I am not sure what you mean by a "list" for output. List is not a data type or structure in base SAS. Do you mean to have them all in one variable separated by spaces or written out as text or what?&lt;/P&gt;
&lt;P&gt;This finds the values and places them in separate variables.&lt;/P&gt;
&lt;PRE&gt;data have;
   Text="Uptime:SSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP remains up";
   array r {20} $ 19; /* this creates 20 variables r1-r20 to hold the "found" names*/
   done=0;
   pos=1; /* start position to search string*/
   counter=1;
   do until (done);
      pos= find(text,'SSA',pos);
      if pos &amp;gt; 0 then do;
         word=substr(text,pos,19);
         /* this next bit searches the array of r values to see if the
            current word which should be the hostname has already been found
            if not assign to the next available r*/
         if whichc(word,of r(*))=0 then do;
            r[counter]=word;
            counter=counter+1;
         end;   
         /* start searching after found host next loop*/
         pos=pos+19;

      end;
      /* if pos=0 then no more SSA to find*/
      Else done=1;

   end;
   drop done counter pos word;
run;&lt;/PRE&gt;
&lt;P&gt;If you want the names in a single variable then adding this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;NameList = catx(&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,of r(*));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;will do so IF the combined lengths do not exceed 200 characters. Again the R array will need to be declared with enough elements to handle all of the unique names you may expect and you will need to ensure that name list is declared with a length of 20 times that number such as&lt;/P&gt;
&lt;P&gt;length NameList $ 2000; if you expect 100 names are likely. the R array would need to be declared with 100 elements (replace the 20).&lt;/P&gt;
&lt;P&gt;If you don't need the R variables after debugging then Drop R: ; will remove all of the variables whose names start with R or use Drop R1 - R100 (with 100 being what ever size you end up for the array).&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2017 00:14:31 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-01-06T00:14:31Z</dc:date>
    <item>
      <title>How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322691#M71415</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to search a variable length field that can be up to 32K and extract hostnames beginning with the letters SSA.&lt;/P&gt;&lt;P&gt;They can be any place in the field.&amp;nbsp;&amp;nbsp;&amp;nbsp; They are all 19 characters long.&amp;nbsp;&amp;nbsp;&amp;nbsp; For example:&amp;nbsp;&amp;nbsp; SSA-COLUMB-MS-N5EF2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carol&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 15:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322691#M71415</guid>
      <dc:creator>CEG</dc:creator>
      <dc:date>2017-01-05T15:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322706#M71421</link>
      <description>&lt;P&gt;You may try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename txt &amp;nbsp;temp 'long_vars';&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file txt; put long_variable_&lt;STRONG&gt;32k&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;data extracted;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;infile txt truncover;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input address &lt;STRONG&gt;$19. ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if index(address,'SSA') &amp;gt; 0 then output;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 16:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322706#M71421</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-05T16:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322724#M71426</link>
      <description>&lt;P&gt;Hi&amp;nbsp; Shmuel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will the index statement extract&amp;nbsp;multiple entries?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will know when to stop searching?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp;&amp;nbsp; I'm a very new user.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322724#M71426</guid>
      <dc:creator>CEG</dc:creator>
      <dc:date>2017-01-05T17:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322725#M71427</link>
      <description>&lt;P&gt;Here's one way that assumes any time you find "SSA-" you want the set of 19 characters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data hostnames;&lt;/P&gt;
&lt;P&gt;infile widedata;&lt;/P&gt;
&lt;P&gt;input;&lt;/P&gt;
&lt;P&gt;do until (ssa_found=0);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ssa_found = index(_infile_, 'SSA-');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if ssa_found then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host = substr(_infile_, found, 19);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _infile_ = substr(_infile_, found+19);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322725#M71427</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-05T17:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322726#M71428</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand there's the possibility to have multiple matches inside the 32K and those could occur at any position.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that's the case, you might need to use the power of regular expression matching, like in the bellow example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; infile '&lt;STRONG&gt;&amp;lt;your_file_here&amp;gt;&lt;/STRONG&gt;' truncover lrecl=32767; &lt;STRONG&gt;* 32K buffer;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; input;&lt;STRONG&gt; * read one line;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; PRX = prxparse('/SSA/'); &lt;STRONG&gt;* set prx pattern to look for;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; START = 1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; STOP = length(_INFILE_);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;* cycle while there is a match;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; POS=1;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; do while (POS &amp;gt; 0);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call prxnext(PRX, START, STOP, _INFILE_, POS, LEN); &lt;STRONG&gt;* search next;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if POS then do;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HOST = substr(_INFILE_, POS, 19); &lt;STRONG&gt;* extract hostname;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; put HOST= 'at position ' POS; &lt;STRONG&gt;* show;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The PRX function family are a powerfull tool for complex/recursive text matching and replacing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More on PRXNEXT here:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295965.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295965.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322726#M71428</guid>
      <dc:creator>Daniel-Santos</dc:creator>
      <dc:date>2017-01-05T17:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322727#M71429</link>
      <description>&lt;P&gt;The index function returns the position of a found string or 0 if not found.&lt;/P&gt;
&lt;P&gt;I'm not sure you can use this function on a variable of 32K bytes, and if it is possible&lt;/P&gt;
&lt;P&gt;than you need code a loop to find all occurences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you pointed that "&lt;SPAN&gt;&lt;STRONG&gt;They are all 19 characters long&lt;/STRONG&gt;" then I preffered looking at it&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;as a 32K block with records each 19 bytes long.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Does it help you?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322727#M71429</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-05T17:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322733#M71432</link>
      <description>Sorry. I didn't explain it very well. The hostnames are all 19 chars, but they can be surrounded by other text. So, I would need a loop.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322733#M71432</guid>
      <dc:creator>CEG</dc:creator>
      <dc:date>2017-01-05T17:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322734#M71433</link>
      <description>Sorry. I didn't explain it very well. The hostnames are all 19 chars, but they can be surrounded by other text. So, I would need a loop.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322734#M71433</guid>
      <dc:creator>CEG</dc:creator>
      <dc:date>2017-01-05T17:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322739#M71436</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Example input and desired output.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Your example need not be exactly 32k but should contain sufficient text to show the entire problem and can be fake data but should be similar to your actual data.&lt;/P&gt;
&lt;P&gt;Next is what would the ouput look like? You find one candidate value what do you do with&amp;nbsp;it? Are you assigning a value to another variable? If so how many additional variables are you likely to need? 32k / 20 characters (allowing for a space to separate them) is potentially 1600 variables.&lt;/P&gt;
&lt;P&gt;If the same hostname is encountered more than once do you need each encountered value or is one sufficient? Is case likely to be an issue for deciding "same hostname" if there is such a rule (i.e is SSA-COLUMB-MS-N5EF2 = SSA-COLUMB-ms-N5EF2).&lt;/P&gt;
&lt;P&gt;Are they &lt;STRONG&gt;always exactly 19 &lt;/STRONG&gt;characters?&lt;/P&gt;
&lt;P&gt;Is there anything in the data starting with SSA that may be 19 characters that is not a host name?&lt;/P&gt;
&lt;P&gt;Are there any special characters other than space, comma or period used to delimit words such as *, @, #, or | that might be adjacent to the hostname and confuse the character count?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322739#M71436</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-05T17:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322825#M71479</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for everyone's help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;A few lines from sample input: Uptime:SSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP remains up&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output should be a list: SSA-COLUMB-MS-N5EF2&lt;BR /&gt;&lt;BR /&gt;SSA-GREENV-MS-N6292&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The hostnames are always caps. One encounter is sufficient. Always 19 chars. There is nothing in the hostname that does not belong.&lt;BR /&gt;&lt;BR /&gt;Can have other characters next to the hostname.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322825#M71479</guid>
      <dc:creator>CEG</dc:creator>
      <dc:date>2017-01-05T22:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322826#M71480</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for everyone's help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;A few lines from sample input: Uptime:SSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP remains up&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output should be a list: SSA-COLUMB-MS-N5EF2&lt;BR /&gt;&lt;BR /&gt;SSA-GREENV-MS-N6292&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The hostnames are always caps. One encounter is sufficient. Always 19 chars. There is nothing in the hostname that does not belong.&lt;BR /&gt;&lt;BR /&gt;Can have other characters next to the hostname.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322826#M71480</guid>
      <dc:creator>CEG</dc:creator>
      <dc:date>2017-01-05T22:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322856#M71484</link>
      <description>&lt;P&gt;I am not sure what you mean by a "list" for output. List is not a data type or structure in base SAS. Do you mean to have them all in one variable separated by spaces or written out as text or what?&lt;/P&gt;
&lt;P&gt;This finds the values and places them in separate variables.&lt;/P&gt;
&lt;PRE&gt;data have;
   Text="Uptime:SSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP remains up";
   array r {20} $ 19; /* this creates 20 variables r1-r20 to hold the "found" names*/
   done=0;
   pos=1; /* start position to search string*/
   counter=1;
   do until (done);
      pos= find(text,'SSA',pos);
      if pos &amp;gt; 0 then do;
         word=substr(text,pos,19);
         /* this next bit searches the array of r values to see if the
            current word which should be the hostname has already been found
            if not assign to the next available r*/
         if whichc(word,of r(*))=0 then do;
            r[counter]=word;
            counter=counter+1;
         end;   
         /* start searching after found host next loop*/
         pos=pos+19;

      end;
      /* if pos=0 then no more SSA to find*/
      Else done=1;

   end;
   drop done counter pos word;
run;&lt;/PRE&gt;
&lt;P&gt;If you want the names in a single variable then adding this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;NameList = catx(&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,of r(*));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;will do so IF the combined lengths do not exceed 200 characters. Again the R array will need to be declared with enough elements to handle all of the unique names you may expect and you will need to ensure that name list is declared with a length of 20 times that number such as&lt;/P&gt;
&lt;P&gt;length NameList $ 2000; if you expect 100 names are likely. the R array would need to be declared with 100 elements (replace the 20).&lt;/P&gt;
&lt;P&gt;If you don't need the R variables after debugging then Drop R: ; will remove all of the variables whose names start with R or use Drop R1 - R100 (with 100 being what ever size you end up for the array).&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 00:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322856#M71484</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-06T00:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322887#M71490</link>
      <description>&lt;P&gt;Looks like a case for a Regular Expression with code pretty much as in this example:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#n1obc9u7z3225mn1npwnassehff0.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#n1obc9u7z3225mn1npwnassehff0.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below sample code assumes the text pattern your host names follow is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ssa
-
6 alphanumeric characters
-
2 alphanumeric characters
-
5 alphanumeric characters.&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;Amend the RegEx in case above assumption is wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  have_str='Uptime:-FrustratedSSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP remains up';
  output;
  stop;
run;

data want(drop=_t_:);
  set have;
  length hos_t_name $19;
  retain _t_prxid 0;
  if _n_=1 then _t_prxid=prxparse('/ssa-\w{6}-\w{2}-\w{5}/i');

  _t_start = 1;
  _t_stop = lengthn(have_str);
    /* Use PRXNEXT to find the first instance of the pattern, */
    /* then use DO WHILE to find all further instances.       */
    /* PRXNEXT changes the _start parameter so that searching  */
    /* begins again after the last match.                     */
  call prxnext(_t_prxid, _t_start, _t_stop, have_str, _t_pos, _t_len);
    do while (_t_pos &amp;gt; 0);
       hos_t_name = substr(have_str, _t_pos, _t_len);
       output;
       call prxnext(_t_prxid, _t_start, _t_stop, have_str, _t_pos, _t_len);
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jan 2017 03:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322887#M71490</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-06T03:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322897#M71496</link>
      <description>&lt;P&gt;As much as I like RegEx, they are overkill here. This suffices:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  STR='Uptime:-FrustratedSSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP remains up';
run;

data WANT;
  set HAVE;
  keep HOST;
  POS=1;
  do while(find(STR,'SSA-',POS));
    HOST=substr(STR,find(STR,'SSA-',POS),19);
    output;
    POS+find(STR,'SSA-',POS)+1;
  end;
run;

proc print noobs; 
run;
    
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellpadding="5" cellspacing="0"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;HOST&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;SSA-COLUMB-MS-N5EF2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;SSA-GREENV-MS-N6292&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 06 Jan 2017 05:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322897#M71496</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-01-06T05:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322900#M71498</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;- there is a typo in your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; line: &amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;POS&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;find&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;STR&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'SSA-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;POS&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should be:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;POS&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;SPAN class="token function"&gt;find&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;STR&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'SSA-'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;POS&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;otherwise the code skips existing hosts.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 11:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322900#M71498</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-06T11:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322930#M71519</link>
      <description>Can't test now but you make sense. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; My code works as shown but would have failed for third match.</description>
      <pubDate>Fri, 06 Jan 2017 10:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/322930#M71519</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-01-06T10:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323088#M71568</link>
      <description>&lt;P&gt;This works better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  STR='Uptime:-FrustratedSSA-COLUMB-MS-N5EF222:49:44SSA-GREENV-MS-N629222:49:47:BGP SSA-GREENV-MS-N629222:49';
run;

data WANT;
  set HAVE;
  keep HOST;
  POS=0;
  do while(find(STR,'SSA-',POS+1));
    POS=find(STR,'SSA-',POS+1);
    HOST=substr(STR,POS,19);
    output;
  end;
run;

proc print noobs; 
run;
    &lt;/CODE&gt;&lt;/PRE&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;</description>
      <pubDate>Fri, 06 Jan 2017 21:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323088#M71568</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-01-06T21:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323107#M71570</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;EM&gt;As much as I like RegEx, they are overkill here.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't agree with you especially because there is an example in the docu which works almost unchanged for the problem at hand.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Your code relies on "SSA-" being sufficient to identify a hostname. May be that's true, may be not. If using a RegEx to begin with then one needs only to amend the RegEx and nothing further in case the pattern "SSA-" doesn't suffice.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 22:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323107#M71570</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-06T22:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323113#M71573</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;That's my point: in this case, the start and the length of the substring to extract are constant and known.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, code that is shorter, much less resource-intensive, easier to read and maintain, and still does the job perfectly is better suited imho.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To each their own.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 22:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323113#M71573</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-01-06T22:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scan a 32K field and extract names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323121#M71575</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This works better:&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maybe the OP will actually tell/show what the output should actually look like. smileyfrustrated:&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 21:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-scan-a-32K-field-and-extract-names/m-p/323121#M71575</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-09T21:05:36Z</dc:date>
    </item>
  </channel>
</rss>

