<?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: Pulling string after phrase and before special charater. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789233#M252512</link>
    <description>Thank you so much! This worked!!!&lt;BR /&gt;&lt;BR /&gt;I have new code to learn about today!</description>
    <pubDate>Mon, 10 Jan 2022 12:16:09 GMT</pubDate>
    <dc:creator>vgriggs</dc:creator>
    <dc:date>2022-01-10T12:16:09Z</dc:date>
    <item>
      <title>Pulling string after phrase and before special charater.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789153#M252481</link>
      <description>&lt;P&gt;I was given an excel file where someone stored all of the information in a single column (var1). I need to pull information but it will be in random orders. Good thing is the person gave the information and then put a period after it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example of Var1:&lt;/P&gt;&lt;P&gt;Type = 2. Size = 4 in x 12 in. Group = ABC grouping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group = A and B Holdings. Type = 1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group = Mark H and Company.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable I need to pull is group. It always starts with "Group = " and has a period in the end. But will be anywhere within the var1 (so you can't name a specific period. Sometimes it may not exist. This variable can be any length in words. I just need to pull the string between "Group = " and the period.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can't be done in excel due to the size of the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried scan, find, splitting at the period, and I am not sure what to do at this point to organize it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jan 2022 18:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789153#M252481</guid>
      <dc:creator>vgriggs</dc:creator>
      <dc:date>2022-01-09T18:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling string after phrase and before special charater.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789173#M252486</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards4 dlm = "0A0D"x;
input Var1 : $ 100.;
cards4;
Type = 2. Size = 4 in x 12 in. Group = ABC grouping.
Group = A and B Holdings. Type = 1. 
Group = Mark H and Company. 
;;;;
run;
proc print;
run;

data want;
  set have;

  do _N_ = 1 to countw(Var1,".");
    part = strip(scan(Var1,_N_,".")); drop part;

    if upcase(part) =: "GROUP" then
      do;
        group = strip(substr(part, index(part, "=")+1));
      end;
  end;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jan 2022 21:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789173#M252486</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-09T21:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling string after phrase and before special charater.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789176#M252487</link>
      <description>&lt;P&gt;You could read the data using NAMED Input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 253px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67243iAA83469F184E78D0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   infile cards4;
   length type size group $48;
   input @;
   _infile_= transtrn(_infile_,' =','=');
   input (_all_)(=);
   list;
   cards4;
Type = 2. Size = 4 in x 12 in. Group = ABC grouping.
Group = A and B Holdings. Type = 1. 
Group = Mark H and Company. 
;;;;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Jan 2022 22:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789176#M252487</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-01-09T22:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling string after phrase and before special charater.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789228#M252509</link>
      <description>&lt;PRE&gt;data have;
infile cards4 truncover;
input Var1 $ 100.;
cards4;
Type = 2. Size = 4 in x 12 in. Group = ABC grouping.
Group = A and B Holdings. Type = 1. 
Group = Mark H and Company. 
;;;;
run;

data want;
 set have;
pid=prxparse('/(?&amp;lt;=group)\s*=[^\.]+(?=\.)/io');
call prxsubstr(pid,var1,p,l);
if p then  want=scan(strip(substr(var1,p,l)),1,'=');
drop pid p l;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 12:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789228#M252509</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-10T12:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling string after phrase and before special charater.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789233#M252512</link>
      <description>Thank you so much! This worked!!!&lt;BR /&gt;&lt;BR /&gt;I have new code to learn about today!</description>
      <pubDate>Mon, 10 Jan 2022 12:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-string-after-phrase-and-before-special-charater/m-p/789233#M252512</guid>
      <dc:creator>vgriggs</dc:creator>
      <dc:date>2022-01-10T12:16:09Z</dc:date>
    </item>
  </channel>
</rss>

