<?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: creating new string variables from a single string variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576790#M163319</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code cannot run for other reasons too, like commas in the data and the DSD option being used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.Do not use MS office files.&lt;/P&gt;
&lt;P&gt;2.Use use {i} or running-man icon to paste your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3.Test the code that you have pasted (copy the code from the web page).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.UC_EPIC_TEST;
  infile datalines pad truncover;
  input NARRATIVE $255. ;
  if index(NARRATIVE,'Indications for Culture:-&amp;gt;') then
    REASON=prxchange('s/\A.*Indications for Culture:-&amp;gt;(.+),Testing performed by.*\Z/\1/',-1,NARRATIVE);
  if REASON =:'Other (specify)' then REASON2 =substr(REASON,36); 
datalines;
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Recent positive UA,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Recent positive UA,RIGHT FLANK NEPH,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Pregnant patient,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;indwelling catheter,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Received in transport media.,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;fever workup,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Received in transport media.,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Received in transport media.,Testing performed by XYZ (123-456-7890) 200000000
Urine culture reflexed based upon urinalysis results.,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;neutropenic pt,Testing performed by XYZ (123-456-7890) 200000000
renal pelvis,Specimen collected in the operating room.,Testing performed by XYZ (123-456-7890) 123456789
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;neutropenic,Testing performed by XYZ (123-456-7890) 123456789
Testing performed by XYZ (123-456-7890) 123456789
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.UC_EPIC_TEST" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;REASON&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;REASON2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Recent positive UA&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Recent positive UA,RIGHT FLANK NEPH&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Pregnant patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;indwelling catheter&lt;/TD&gt;
&lt;TD class="l data"&gt;indwelling catheter&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;fever workup&lt;/TD&gt;
&lt;TD class="l data"&gt;fever workup&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;neutropenic pt&lt;/TD&gt;
&lt;TD class="l data"&gt;neutropenic pt&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;neutropenic&lt;/TD&gt;
&lt;TD class="l data"&gt;neutropenic&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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, 26 Jul 2019 03:18:30 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-07-26T03:18:30Z</dc:date>
    <item>
      <title>creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576749#M163289</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I have a string variable called &lt;STRONG&gt;narrative&lt;/STRONG&gt;.&amp;nbsp; If the variable narrative contains "Indications for Culture" in the text, then I need to create a new variable called &lt;STRONG&gt;reason&lt;/STRONG&gt;&amp;nbsp;which captures the text after&amp;nbsp;Indications for Culture:-&amp;amp;gt;&amp;nbsp; till , right before the Testing performed by XYZ (123-456-7890).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; Indication for culture can appear at any position within the string variable&amp;nbsp;narrative&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, i.e. if the &lt;STRONG&gt;reason&lt;/STRONG&gt; is Other (specify) then I need to create another variable &lt;STRONG&gt;Reason_other&lt;/STRONG&gt; and need to capture the text after&amp;nbsp;&lt;STRONG&gt;Other Indication:-&amp;amp;gt;&amp;nbsp;&lt;/STRONG&gt;till,&amp;nbsp;right before the Testing performed by XYZ (123-456-7890).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the narrative contains only Other Indication:-&amp;amp;gt; and not Indications for Culture:-&amp;amp;gt; then I need to have&amp;nbsp;&lt;STRONG&gt;Reason_other&amp;nbsp;&lt;/STRONG&gt;and need to capture the text after&amp;nbsp;Other Indication:-&amp;amp;gt;&amp;nbsp;till,&amp;nbsp;right before the Testing performed by XYZ (123-456-7890)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want&amp;nbsp;Testing performed by XYZ (123-456-7890)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 21:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576749#M163289</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2019-07-25T21:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576754#M163293</link>
      <description>Is your data already in a SAS data set?</description>
      <pubDate>Thu, 25 Jul 2019 22:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576754#M163293</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-25T22:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576755#M163294</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 22:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576755#M163294</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2019-07-25T22:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576756#M163295</link>
      <description>&lt;P&gt;Can you post some of that using the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are instructions on how to provide sample data as a data step:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 22:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576756#M163295</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-25T22:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576759#M163296</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
 &amp;nbsp; &amp;nbsp; &amp;nbsp; check1 = "Indications for Culture:-&amp;amp;gt; ";
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;len1 = length(check1);
  &amp;nbsp; &amp;nbsp; &amp;nbsp;check2 = "Other Indication:-&amp;amp;gt;";
       len2 = length(check2);

       ix1 = index(narrative,check1);
       if ix1 then do;
                reason_length = index(substr(narrative,ix1+len1+1), ','); 
                reason = substr(narrative,ix1+len1+1, reason_length);
       end;

       ix2 = index(narrative,check2);
       if ix2 then do;
                other_length = index(substr(narrative,ix2+len2+1), ','); 
                reason_other = substr(narrative,ix2+len2+1, other_length);
       end;&lt;BR /&gt;       drop ix1 ix2 check1 check2 reason_length other_length;
run; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 22:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576759#M163296</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-07-25T22:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576760#M163297</link>
      <description>&lt;P&gt;Here is the data set:&lt;/P&gt;&lt;P&gt;data WORK.UC_EPIC_TEST;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input Narrative:$255. ID:$57.;&lt;BR /&gt;label Narrative="Narrative";&lt;BR /&gt;datalines;&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Urology patient,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Recent positive UA,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890) 200000000&lt;/SPAN&gt;&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Recent positive UA,RIGHT FLANK NEPH,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Pregnant patient,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&amp;nbsp;200000000&lt;/SPAN&gt;&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Urology patient,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;indwelling catheter,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Urology patient,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&amp;nbsp;200000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Urology patient,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&amp;nbsp;200000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Received in transport media.,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;fever workup,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Received in transport media.,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Received in transport media.,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Urine culture reflexed based upon urinalysis results.,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;neutropenic pt,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 200000000&lt;BR /&gt;renal pelvis,Specimen collected in the operating room.,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 123456789&lt;BR /&gt;Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;neutropenic,&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 123456789&lt;BR /&gt;&lt;SPAN&gt;Testing performed by XYZ (123-456-7890)&lt;/SPAN&gt; 123456789&lt;BR /&gt;;;;;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 22:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576760#M163297</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2019-07-25T22:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576773#M163304</link>
      <description>&lt;P&gt;Click&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; 's link, read it, and edit your post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S.: I pasted your code into SAS, got an error, and went to the next question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.P.S: Investigate SAS' support for regular expressions, as well as researching regular expressions themselves.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 00:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576773#M163304</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-07-26T00:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576782#M163312</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp; I think that is the output of the code, but&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp;needs to post it into a code window. As posted, it's been garbled, I think, so can't be sure of how to accomplish this because I don't know what the delimiter is in the real data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Click&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; 's link, read it, and edit your post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S.: I pasted your code into SAS, got an error, and went to the next question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.P.S: Investigate SAS' support for regular expressions, as well as researching regular expressions themselves.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 02:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576782#M163312</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-26T02:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576790#M163319</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code cannot run for other reasons too, like commas in the data and the DSD option being used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.Do not use MS office files.&lt;/P&gt;
&lt;P&gt;2.Use use {i} or running-man icon to paste your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3.Test the code that you have pasted (copy the code from the web page).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.UC_EPIC_TEST;
  infile datalines pad truncover;
  input NARRATIVE $255. ;
  if index(NARRATIVE,'Indications for Culture:-&amp;gt;') then
    REASON=prxchange('s/\A.*Indications for Culture:-&amp;gt;(.+),Testing performed by.*\Z/\1/',-1,NARRATIVE);
  if REASON =:'Other (specify)' then REASON2 =substr(REASON,36); 
datalines;
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Recent positive UA,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Recent positive UA,RIGHT FLANK NEPH,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Pregnant patient,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;indwelling catheter,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Urology patient,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Received in transport media.,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;fever workup,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Received in transport media.,Testing performed by XYZ (123-456-7890) 200000000
Testing performed by XYZ (123-456-7890) 200000000
Received in transport media.,Testing performed by XYZ (123-456-7890) 200000000
Urine culture reflexed based upon urinalysis results.,Testing performed by XYZ (123-456-7890) 200000000
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;neutropenic pt,Testing performed by XYZ (123-456-7890) 200000000
renal pelvis,Specimen collected in the operating room.,Testing performed by XYZ (123-456-7890) 123456789
Indications for Culture:-&amp;gt;Other (specify),Other Indication:-&amp;gt;neutropenic,Testing performed by XYZ (123-456-7890) 123456789
Testing performed by XYZ (123-456-7890) 123456789
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.UC_EPIC_TEST" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;REASON&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;REASON2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Recent positive UA&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Recent positive UA,RIGHT FLANK NEPH&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Pregnant patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;indwelling catheter&lt;/TD&gt;
&lt;TD class="l data"&gt;indwelling catheter&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Urology patient&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;fever workup&lt;/TD&gt;
&lt;TD class="l data"&gt;fever workup&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;neutropenic pt&lt;/TD&gt;
&lt;TD class="l data"&gt;neutropenic pt&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Other (specify),Other Indication:-&amp;gt;neutropenic&lt;/TD&gt;
&lt;TD class="l data"&gt;neutropenic&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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, 26 Jul 2019 03:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/576790#M163319</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-26T03:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/577031#M163441</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.UC_&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;Data work.Uc_Test1;
Set work.Uc_Test;
*Identifying isolated cultures;
if Narrative =: 'Indications for Culture' or Accession =: 'Indications for Culture' then Isolated_Uc = 1;
else Isolated_Uc = 0;

if Narrative =: 'Urine culture reflexed based upon urinalysis results' or Accession =: 'Urine culture reflexed based upon urinalysis results' then UAReflexUc = 1;
else UAReflexUc = 0;

*Reason for isolated urince culture;
if Isolated_Uc = 1 then Reason_Isolated_Uc = scan(Narrative, 2, ";,");
*Reason for isolated urince culture;
if Isolated_Uc = 1 then Reason_Oth_Iso = scan(Narrative, 3, ";,,");
run;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TEST; infile datalines dsd truncover; input Narrative:$255.; label Narrative="Narrative"; datalines; right renal pelvis,Specimen collected in the operating room.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Add to most recent UA.,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) After catheter change,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) After foley changed,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) BEFORE STARTING ABX,Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;Neutropenic fever,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Before discharge,Indications for Culture:-&amp;amp;gt;Urology patient,Specimen received in a sterile container.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Bladder urine for routine culture,Specimen collected in the operating room.,Specimen received in a sterile container.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Bladder urine for routine culture,Specimen collected in the operating room.,Specimen received in a sterile container.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Bladder urine for routine culture,Specimen collected in the operating room.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Catheter placed 8/5. Please send from catheter specimen.,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Clean catch after Foley removed,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Collect from Foley,Indications for Culture:-&amp;amp;gt;Urology patient,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Collected at time of insertion of new foley,Indications for Culture:-&amp;amp;gt;Urology patient,Specimen received in a sterile container.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Collected directly for Foley replacement,May use urine already collected if available.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Draw prior to antibiotics given,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) From LEFT PCN,Indications for Culture:-&amp;amp;gt;Urology patient,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) From RIGHT PCN,Indications for Culture:-&amp;amp;gt;Urology patient,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) From new catheter,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) He actually does need a culture, specimen from this AM was rejected due to suspected contamination,Indications for Culture:-&amp;amp;gt;Recent positive UA,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) If urine protein creatinine ratio not collected, please send along with urine culture,Indications for Culture:-&amp;amp;gt;Recent positive UA,Specimen received in a sterile container.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;+ blood cultures,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;? bacteremia,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI bundle,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI in neutropenic patient,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI in renal allograft,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Specimen received in a sterile container.,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AKI,Testing performed by Aaaaaa-Bbbbbb Cccccccc Dddddddddddd Eeeeeeeeee (111-222-3333) Indications for Culture:-&amp;amp;gt;Other (specify),Other Indication:-&amp;amp;gt;AMS, hypotension,Specimen received in a sterile container. ;;;; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for all who responded. I am attaching the SAS dataset.&amp;nbsp; I tried the following code but I am not able to get the Other Indication reasonn if the Indication for Culture is Other (specify).&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 18:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/577031#M163441</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2019-07-26T18:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/577254#M163562</link>
      <description>1. You code doesn;t run
2. What's wrong with the proposed methods?</description>
      <pubDate>Sun, 28 Jul 2019 21:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/577254#M163562</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-28T21:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: creating new string variables from a single string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/577292#M163582</link>
      <description>&lt;P&gt;I tried to run your data and decided:&lt;/P&gt;
&lt;P&gt;1) to save data as .txt file - see attached file test8.txt&lt;/P&gt;
&lt;P&gt;2) define delimiter as &amp;lt;line feed&amp;gt; '012'x;&lt;/P&gt;
&lt;P&gt;3) fixed my posted code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are invited to test it. Please post details in case of issues.&lt;/P&gt;
&lt;P&gt;It seems to me that next code works fine:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test '/folders/myfolders/myfolders/flat/test8.txt';
data TEST; 
infile test dsd truncover dlm='12'x; 
input Narrative:$255.; 
label Narrative="Narrative"; 
run;

data want;
  set test;
       check1 = 'Indications for Culture:-&amp;amp;gt;';
       len1 = length(check1);
       check2 = 'Other Indication:-&amp;amp;gt;';
       len2 = length(check2);

       ix1 = index(narrative,check1); put _N_ ix1=;
       if ix1 then do;
          desc = check1;
          reason_length = index(substr(narrative,ix1+len1+1), ','); 
          reason = substr(narrative,ix1+len1, reason_length);
       end;

       ix2 = index(narrative,check2); put _N_ ix2=;
       if ix2 then do;
          desc = check2;
          other_length = index(substr(narrative,ix2+len2+1), ','); 
          reason_other = substr(narrative,ix2+len2, other_length);
       end;     &lt;BR /&gt;       if not missing(desc);  
       keep desc reason reason_other;
run;    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jul 2019 18:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-string-variables-from-a-single-string-variable/m-p/577292#M163582</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-07-29T18:33:03Z</dc:date>
    </item>
  </channel>
</rss>

