<?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: Parse prxmatch and remove unwanted text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850797#M336220</link>
    <description>&lt;P&gt;LOL! No problem - that's fixable, for sure. Glad you're back on track&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Dec 2022 15:13:36 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2022-12-22T15:13:36Z</dc:date>
    <item>
      <title>Parse prxmatch and remove unwanted text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850657#M336175</link>
      <description>&lt;P&gt;Good morning.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using the attached code to document all tables in my code (thanks to others as I'd have never figured this out on my own). However, I'd like the result to be a bit cleaner.&lt;/P&gt;
&lt;P&gt;For instance, you can see that a number of entries contains the leading words SEQ and MULTI as well as the trailing words.DATA and .VIEW. I'd like to remove those before the Excel file creation. I've never used this type of code so I'd appreciate any help someone could give me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc scaproc;
write;
run;

filename sca_rec "&amp;amp;documentation.\&amp;amp;documentation_name..txt";
filename sca_rec '&amp;lt;&amp;lt;SCAPROC TEXT FILE';

data myinfo;

infile sca_rec truncover;
input @1 scaline $256.;
length type myinfo $100;
keep type myinfo;
retain prxifile prxidata;

if _n_ = 1 then do;
	prxifile = prxparse("!\bJOBSPLIT: FILE INPUT SEQ (\b.*\b) \*/!");
	prxidata = prxparse("!\bJOBSPLIT: DATASET INPUT (\b.*\b) \*/!");
end;

	if prxmatch (prxidata,scaline) &amp;gt; 0 then do;
		myinfo = prxposn(prxidata,1,scaline);
		type = 'Input File';
		output myinfo;
	end;
run;

proc export data = myinfo
	outfile = '&amp;lt;&amp;lt;outfile path&amp;gt;&amp;gt;'
/*	putnames = no;*/
	dbms = xls replace;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Dec 2022 18:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850657#M336175</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2022-12-21T18:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Parse prxmatch and remove unwanted text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850676#M336177</link>
      <description>&lt;P&gt;One approach woud be to re-write the regular expression to capture just the text you want, but that can be complex if you are not familiar with REGEX writing. Another approach would be to process the result using SAS functions. So, in your program, the result of the expression:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myinfo = prxposn(prxidata,1,scaline);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Yields:&lt;/P&gt;
&lt;PRE&gt;MULTI VIEWSDT.FILE1.VIEW&lt;/PRE&gt;
&lt;P&gt;To get rid of all the text before that first space, you could add SCAN:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myinfo = scan(prxposn(prxidata,1,scaline),-1,' ');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which now yields:&lt;/P&gt;
&lt;PRE&gt;VIEWSDT.FILE1.VIEW&lt;/PRE&gt;
&lt;P&gt;If you want to also remove that last "word" after the period, you re-process the result using SUBSTR and FIND like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myinfo = SUBSTR(myinfo,1,FIND(myinfo,'.',-9999)-1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which now yields:&lt;/P&gt;
&lt;PRE&gt;VIEWSDT.FILE1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Just be aware that, when the value extracted is something like "SEQ LIST.DATA", the end result will be just "LIST".&amp;nbsp;&amp;nbsp;Is that what you were envisioning?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 20:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850676#M336177</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-12-21T20:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Parse prxmatch and remove unwanted text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850677#M336178</link>
      <description>&lt;P&gt;I think so. At least it gets me way close. Thanks very much for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 20:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850677#M336178</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2022-12-21T20:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Parse prxmatch and remove unwanted text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850679#M336179</link>
      <description>&lt;P&gt;Well there's a newbie error. I accepted my own post as a solution, sigh. Sorry, that should have been awarded to you.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 21:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850679#M336179</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2022-12-21T21:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Parse prxmatch and remove unwanted text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850797#M336220</link>
      <description>&lt;P&gt;LOL! No problem - that's fixable, for sure. Glad you're back on track&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 15:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parse-prxmatch-and-remove-unwanted-text/m-p/850797#M336220</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-12-22T15:13:36Z</dc:date>
    </item>
  </channel>
</rss>

