<?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: Extract &amp;quot;Day #&amp;quot; from a string of text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808821#M318925</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311553"&gt;@mariko5797&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to make the days listed in the "Comments" column as it's own column. I would prefer each day to be it's own row.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Example:&lt;/EM&gt; If COMMENTS = "No assessment made on Day 16, Day 17, Day 19" then I would extract DAYS = 16, 17, 19&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Example:&lt;/EM&gt; If COMMENTS = "No assessment made on Day 16, Day 17, Day 19" then I would extract &lt;FONT color="#FF0000"&gt;DAYS = 16 on one row, DAYS = 17 on another row, and DAYS= 19 on another row&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Apr 2022 13:53:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-04-20T13:53:05Z</dc:date>
    <item>
      <title>Extract "Day #" from a string of text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808819#M318923</link>
      <description>&lt;P&gt;I want to make the days listed in the "Comments" column as it's own column. I would prefer each day to be it's own row.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Example:&lt;/EM&gt; If COMMENTS = "No assessment made on Day 16, Day 17, Day 19" then I would extract DAYS = 16, 17, 19&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 13:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808819#M318923</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-20T13:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract "Day #" from a string of text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808821#M318925</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311553"&gt;@mariko5797&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to make the days listed in the "Comments" column as it's own column. I would prefer each day to be it's own row.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Example:&lt;/EM&gt; If COMMENTS = "No assessment made on Day 16, Day 17, Day 19" then I would extract DAYS = 16, 17, 19&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Example:&lt;/EM&gt; If COMMENTS = "No assessment made on Day 16, Day 17, Day 19" then I would extract &lt;FONT color="#FF0000"&gt;DAYS = 16 on one row, DAYS = 17 on another row, and DAYS= 19 on another row&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 13:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808821#M318925</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-20T13:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extract "Day #" from a string of text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808860#M318941</link>
      <description>&lt;P&gt;so you want days to be a character variable with the days from comment variable? could you post some sample data as datelines and desired output?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 15:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/808860#M318941</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-04-20T15:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extract "Day #" from a string of text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/809234#M319090</link>
      <description>&lt;P&gt;Something like this may work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  prxid=prxparse('/\bDay\s+\d+\b/i');
  start=1;
  end=length(comments);
  do until(0);
    call prxnext(prxid,start,end,comments,pos,len);
    if pos=0 then leave;
    day=input(scan(substr(comments,pos,len),2),8.0);
    output;
    end;
  drop start end pos len prxid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The PRX expression looks for a word boundary (\b), followed by "Day" and 1 or more whitespaces (blanks or tab characters) (\s+), 1 or more digits (\d+) and a word boundary again. The "i" at the end means to look for e.g. both "day", "DAY" and "Day".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the DAY as a character variable, just drop the INPUT function (and perhaps declare the DAY variable with e.g "length day $8;" as it will otherwise get the same length as the COMMENTS variable).&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 08:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-quot-Day-quot-from-a-string-of-text/m-p/809234#M319090</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-04-22T08:08:31Z</dc:date>
    </item>
  </channel>
</rss>

