<?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: Issue with PROC GROOVY macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906239#M357846</link>
    <description>&lt;P&gt;From your log, it looks like the SAS system can't read the image file KMEDirect.png. I'm assuming you already opened the image file in a viewer to ensure it's not corrupted. I&amp;nbsp;compiled your macro, then ran these two calls to test it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dir=c:/temp;
%let filename1=picture1.png;
%let filename2=picture2.png;
%let filename_out=picture_out.png;

%dtt_compare_figure(
  infile1 = &amp;amp;dir/&amp;amp;filename1,
  infile2 = &amp;amp;dir/&amp;amp;filename2,
  outfile = &amp;amp;dir/&amp;amp;filename_out
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With this result:&lt;/P&gt;
&lt;PRE&gt;MPRINT(DTT_COMPARE_FIGURE):   PROC GROOVY;
MPRINT(DTT_COMPARE_FIGURE):   SUBMIT "c:/temp/picture1.png" "c:/temp/picture2.png"
"c:/temp/picture_out.png";
Compare picture c:/temp/picture1.png
No changes found: c:/temp/picture1.png
NOTE: The SUBMIT command completed.
MPRINT(DTT_COMPARE_FIGURE):   QUIT;

NOTE: PROCEDURE GROOVY used (Total process time):
      real time           0.05 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;And this call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let filename3=picture3.png;
%let filename13_out=picture13_out.png;
%dtt_compare_figure(
  infile1 = &amp;amp;dir/&amp;amp;filename1,
  infile2 = &amp;amp;dir/&amp;amp;filename3,
  outfile = &amp;amp;dir/&amp;amp;filename13_out
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with this result:&lt;/P&gt;
&lt;PRE&gt;MPRINT(DTT_COMPARE_FIGURE):   PROC GROOVY;
MPRINT(DTT_COMPARE_FIGURE):   SUBMIT "c:/temp/picture1.png" "c:/temp/picture3.png"
"c:/temp/picture13_out.png";
Compare picture c:/temp/picture1.png
ERROR: Height and/or Weight for both images are not equal.
NOTE: The SUBMIT command completed.
MPRINT(DTT_COMPARE_FIGURE):   QUIT;

NOTE: PROCEDURE GROOVY used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;So the macro seems to be working. I'm attaching a ZIP file with the images I used for testing. Try running the same macro calls I ran against the images I provided. If that works for you, your original image files may not be readable from your SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Dec 2023 14:39:44 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2023-12-05T14:39:44Z</dc:date>
    <item>
      <title>Issue with PROC GROOVY macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906212#M357843</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm trying to use this macro&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO dtt_compare_figure(infile1=, infile2=, outfile=);
 FILENAME cmd8295 TEMP;
 DATA _NULL_;
 FILE cmd8295 LRECL=500;
 PUT 'PROC GROOVY; ';
 PUT ' SUBMIT "&amp;amp;infile1" "&amp;amp;infile2" "&amp;amp;outfile"; ';
 PUT ' import java.awt.image.BufferedImage; ';
 PUT ' import java.awt.Color; ';
 PUT ' import javax.imageio.ImageIO; ';
 PUT ' ';
 PUT ' final int RED_COLOR = new Color(255, 0, 0).getRGB(); ';
 PUT ' ';
 PUT ' String image1 = args[0]; ';
 PUT ' String image2 = args[1]; ';
 PUT ' String out = args[2]; ';
 PUT ' ';
 PUT ' System.out.println("Compare picture " + image1); ';
 PUT ' ';
 PUT ' File fileImage1 = new File(image1); ';
 PUT ' File fileImage2 = new File(image2); ';
 PUT ' File fileOut = new File(out); ';
 PUT ' ';
 PUT ' BufferedImage img1=null; ';
 PUT ' BufferedImage img2=null; ';
 PUT ' img1 = ImageIO.read(fileImage1); ';
 PUT ' img2 = ImageIO.read(fileImage2); ';
 PUT ' ';
 PUT ' int pixelDiff = 0; ';
 PUT ' if (img1.getWidth() == img2.getWidth() &amp;amp;&amp;amp; img1.getHeight() == img2.getHeight()) { ';
 PUT ' for (int x = 0; x &amp;lt; img1.getWidth(); x++) { ';
 PUT ' for (int y = 0; y &amp;lt; img1.getHeight(); y++) { ';
 PUT ' if (img1.getRGB(x, y) != img2.getRGB(x, y)) { ';
 PUT ' pixelDiff++; ';
 PUT ' img2.setRGB(x, y, RED_COLOR); ';
 PUT ' } ';
 PUT ' } ';
 PUT ' } ';
 PUT ' } else { ';
 PUT ' System.out.println("ERROR: Height and/or Weight for both images are not equal."); ';
 PUT ' return; ';
 PUT ' } ';
 PUT ' if (pixelDiff != 0) { ';
 PUT ' System.out.println("WARNING: " + pixelDiff + " changes found for " + image1); ';
 PUT ' ImageIO.write(img2, "png", fileOut); ';
 PUT ' } else { ';
 PUT ' System.out.println("No changes found: " + image1); ';
 PUT ' } ';
 PUT ' ENDSUBMIT; ';
 PUT 'QUIT; ';
 RUN;
 %INCLUDE cmd8295;
 FILENAME cmd8295;
%MEND dtt_compare_figure;

%dtt_compare_figure(
  infile1 = &amp;amp;dir/&amp;amp;filename1..png,
  infile2 = &amp;amp;dir/&amp;amp;filename2..png,
  outfile = &amp;amp;dir/&amp;amp;filename_out..png
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have directed infile1 and infile2 to the correct file locations but I keep getting this error no matter what examples&amp;nbsp; I try to use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_0-1701769368126.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90798i0FE521716FC9D64D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1701769368126.png" alt="smackerz1988_0-1701769368126.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm using SAS EG on a remote server but when I use more simple PROC GROOVY code it works fine such as this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO sayHello(name);
FILENAME cmdFile TEMP;
DATA _NULL_;
FILE cmdFile LRECL=500;
PUT 'PROC GROOVY; ';
PUT ' SUBMIT "&amp;amp;name"; ';
PUT ' String name = args[0]; ';
PUT ' System.out.println("Hello " + name + "!");';
PUT ' ENDSUBMIT; ';
PUT 'QUIT; ';
RUN;
%INCLUDE cmdFile;
%MEND sayHello;
%sayHello(Stephen);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_0-1701769771532.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90799i657A5C956C4FBEE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1701769771532.png" alt="smackerz1988_0-1701769771532.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help on this matter would be greatly appreciated&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 09:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906212#M357843</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2023-12-05T09:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with PROC GROOVY macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906239#M357846</link>
      <description>&lt;P&gt;From your log, it looks like the SAS system can't read the image file KMEDirect.png. I'm assuming you already opened the image file in a viewer to ensure it's not corrupted. I&amp;nbsp;compiled your macro, then ran these two calls to test it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dir=c:/temp;
%let filename1=picture1.png;
%let filename2=picture2.png;
%let filename_out=picture_out.png;

%dtt_compare_figure(
  infile1 = &amp;amp;dir/&amp;amp;filename1,
  infile2 = &amp;amp;dir/&amp;amp;filename2,
  outfile = &amp;amp;dir/&amp;amp;filename_out
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With this result:&lt;/P&gt;
&lt;PRE&gt;MPRINT(DTT_COMPARE_FIGURE):   PROC GROOVY;
MPRINT(DTT_COMPARE_FIGURE):   SUBMIT "c:/temp/picture1.png" "c:/temp/picture2.png"
"c:/temp/picture_out.png";
Compare picture c:/temp/picture1.png
No changes found: c:/temp/picture1.png
NOTE: The SUBMIT command completed.
MPRINT(DTT_COMPARE_FIGURE):   QUIT;

NOTE: PROCEDURE GROOVY used (Total process time):
      real time           0.05 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;And this call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let filename3=picture3.png;
%let filename13_out=picture13_out.png;
%dtt_compare_figure(
  infile1 = &amp;amp;dir/&amp;amp;filename1,
  infile2 = &amp;amp;dir/&amp;amp;filename3,
  outfile = &amp;amp;dir/&amp;amp;filename13_out
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with this result:&lt;/P&gt;
&lt;PRE&gt;MPRINT(DTT_COMPARE_FIGURE):   PROC GROOVY;
MPRINT(DTT_COMPARE_FIGURE):   SUBMIT "c:/temp/picture1.png" "c:/temp/picture3.png"
"c:/temp/picture13_out.png";
Compare picture c:/temp/picture1.png
ERROR: Height and/or Weight for both images are not equal.
NOTE: The SUBMIT command completed.
MPRINT(DTT_COMPARE_FIGURE):   QUIT;

NOTE: PROCEDURE GROOVY used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;So the macro seems to be working. I'm attaching a ZIP file with the images I used for testing. Try running the same macro calls I ran against the images I provided. If that works for you, your original image files may not be readable from your SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 14:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906239#M357846</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-12-05T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with PROC GROOVY macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906263#M357852</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;Thank you so much! I believe the issue is the current read-write permission with the temporary cmdfile that is masking the proc groovy code. I have followed up with IT.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 16:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-PROC-GROOVY-macro/m-p/906263#M357852</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2023-12-05T16:25:43Z</dc:date>
    </item>
  </channel>
</rss>

