<?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: Debugging PROC DS2 and PROC FEDSQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471110#M120635</link>
    <description>&lt;P&gt;Trying out this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2;
	package regexp / overwrite=yes;
		method match( char pattern, char string ) returns integer;
			return prxmatch(pattern, string);
		end;
	run;
quit;


data raw;
	input id $11.;
	datalines;
10000100002
10000000002
;
run;


PROC FEDSQL;
	DROP TABLE example FORCE;
  CREATE TABLE example (
    is_valid INTEGER
  );
QUIT;


PROC FEDSQL;
  INSERT INTO example
  SELECT regexp.match('/\d+/', id)
  FROM raw;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So I should be see a 1 for each row of raw in example.&amp;nbsp; It's working just fine on my regular expressions utility.&amp;nbsp; However regular expressions fails to find a match.&amp;nbsp; I'm getting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&lt;BR /&gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is clearly incorrect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jun 2018 14:49:10 GMT</pubDate>
    <dc:creator>tomcmacdonald</dc:creator>
    <dc:date>2018-06-18T14:49:10Z</dc:date>
    <item>
      <title>Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471082#M120620</link>
      <description>&lt;P&gt;Are there any debugging options I can set?&amp;nbsp; I'm having trouble incorporating a PROC DS2 package into PROC FEDSQL receiving the following cryptic error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR: Access Violation occurred during PREPARE!&lt;/PRE&gt;&lt;P&gt;Not really sure how to proceed with this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 13:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471082#M120620</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-06-18T13:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471092#M120627</link>
      <description>&lt;P&gt;Trying out the PUTLOG statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n05jha8tsrpanyn19m05ss7ltv6e.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n05jha8tsrpanyn19m05ss7ltv6e.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2 scond=note;
	package regexp / overwrite=yes;
		method match( char pattern, char string ) returns integer;
			putlog pattern;
			putlog string;
			return prxmatch(trim(pattern), string);
		end;
	run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm thinking SAS will treat each paramter as a string and print it to the log put that doesn't work.&amp;nbsp; I'm getting this error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;24         proc ds2 scond=note;
25         	package regexp / overwrite=yes;
26         		method match( char pattern, char string ) returns integer;
27         			putlog pattern;
28         			putlog string;
29         			return prxmatch(pattern, string);
30         		end;
31         	run;
ERROR: Compilation error.
ERROR: Parse encountered identifier when expecting one of: '=' '-' '+'.
ERROR: Line 27: Parse failed: putlog  &amp;gt;&amp;gt;&amp;gt; pattern &amp;lt;&amp;lt;&amp;lt; ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 14:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471092#M120627</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-06-18T14:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471095#M120629</link>
      <description>&lt;P&gt;OK how about just regular put?&amp;nbsp; Will that print to log when executing the function?&amp;nbsp; Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2 scond=note;
	package regexp / overwrite=yes;
		method match( char pattern, char string ) returns integer;
			put pattern;
			return prxmatch(pattern, string);
		end;
	run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;OK it compiles but doesn't print anything to the log when I invoke the function.&amp;nbsp; So that didn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really thought this one would work looking at this help file on page 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings17/0916-2017.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings17/0916-2017.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 14:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471095#M120629</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-06-18T14:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471110#M120635</link>
      <description>&lt;P&gt;Trying out this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2;
	package regexp / overwrite=yes;
		method match( char pattern, char string ) returns integer;
			return prxmatch(pattern, string);
		end;
	run;
quit;


data raw;
	input id $11.;
	datalines;
10000100002
10000000002
;
run;


PROC FEDSQL;
	DROP TABLE example FORCE;
  CREATE TABLE example (
    is_valid INTEGER
  );
QUIT;


PROC FEDSQL;
  INSERT INTO example
  SELECT regexp.match('/\d+/', id)
  FROM raw;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So I should be see a 1 for each row of raw in example.&amp;nbsp; It's working just fine on my regular expressions utility.&amp;nbsp; However regular expressions fails to find a match.&amp;nbsp; I'm getting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&lt;BR /&gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is clearly incorrect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 14:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471110#M120635</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-06-18T14:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471118#M120641</link>
      <description>&lt;P&gt;OK this however works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FEDSQL;
  INSERT INTO example
  SELECT regexp.match('/[0-9]+/', id)
  FROM raw;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So SAS regular expressions isn't strictly compliant with the PERL regular expression standard. Looks like shorthands like \d and \w are out unfortunately.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That isn't true.&amp;nbsp; I wasn't escaping the backslash character.&amp;nbsp; This works.&amp;nbsp; Any way for SAS to interpret parameters as raw strings?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FEDSQL;
  INSERT INTO example
  SELECT regexp.match('/\\d+/', id)
  FROM raw;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jun 2018 14:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471118#M120641</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-06-18T14:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471124#M120644</link>
      <description>&lt;P&gt;Still cannot solve the problem of logging a parameter from a PROC DS2 package. The put statement simply does not work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2;
	package regexp / overwrite=yes;
		method match( varchar(1024) pattern, char string ) returns integer;
			put 'foobar';
			return prxmatch(pattern, string);
		end;
	run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's disappointing about this is I'm reading an example from&amp;nbsp;Mastering the SAS DS2 Procedure: Advanced Data Wrangling Techniques on page 62 with a similar user defined package with put statements.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 15:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/471124#M120644</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-06-18T15:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Debugging PROC DS2 and PROC FEDSQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/472954#M121311</link>
      <description>&lt;P&gt;If you create a package, it is just stored on disk. None of the methods will execute until you instantiate the package and call the method from a DATA program.&amp;nbsp;&amp;nbsp;For example,&amp;nbsp; I think this produces the result you're looking for:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2;
	package regexp / overwrite=yes;
		method match( varchar(1024) pattern, char string ) returns integer;
			put 'foobar';
			return prxmatch(pattern, string);
		end;
   endpackage;
	run;
   data _null_;
      dcl package regexp r();
      method init();
         dcl int rc;
         rc=r.match('/\d+/','10000100002');
         put rc=;
     end;         
   enddata;
   run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;the result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;57      data _null_;
58         dcl package regexp r();
59         method init();
60            dcl int rc;
61            rc=r.match('/\d+/','10000100002');
62            put rc=;
63        end;
64      enddata;
65      run;
foobar
rc=1
NOTE: Execution succeeded. No rows affected.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jun 2018 12:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Debugging-PROC-DS2-and-PROC-FEDSQL/m-p/472954#M121311</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2018-06-25T12:17:25Z</dc:date>
    </item>
  </channel>
</rss>

