<?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: proc report #byval logic for images in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707780#M217359</link>
    <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're right, I was reading through your paper which was very helpful. &lt;/P&gt;
&lt;P&gt;Actually I found a solution in &lt;A title="proc report dynamic image ref" href="http://de.saswiki.org/images/f/f7/18_KSFE_2014_Wern_-_PROC_REPORT_-_Decathlon.pdf" target="_self"&gt;http://de.saswiki.org/images/f/f7/18_KSFE_2014_Wern_-_PROC_REPORT_-_Decathlon.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here comes the code which is working for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on;
options missing=' ';
proc report data=dna.all spanrows nowd style(report)=[rules=none frame=void linethickness=4 ];
where lowcase(brand) ne "other";

title 'KPI overview';
column logo brand producto  ren fin  kpi ;
define brand / group noprint;
define producto / group ;
define ren / sum;
define fin / sum;
define logo / computed  ;
define kpi / computed f=percent9.1;
break before brand / summarize; 
/* rbreak after / summarize; */

compute kpi;
kpi = ren.sum / fin.sum;
if strip(_break_) not in ("_RBREAK_" "" ) then CALL DEFINE('LOGO','STYLE',"STYLE=
{PREIMAGE='/caslibs/marketing/" ||TRIM(lowcase(brand))|| ".png?height=3cm'}");
endcomp;

run;.&amp;nbsp;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Dec 2020 23:01:19 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2020-12-22T23:01:19Z</dc:date>
    <item>
      <title>proc report #byval logic for images</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707736#M217339</link>
      <description>&lt;P&gt;How Do I assign by-group images?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Imagine that for both by group values "Asia" and "Canada" I have 2 png's with the same naming?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data SHOES;
set SASHELP.SHOES;
run;

proc sort data=shoes;
by region product;
run;


ods graphics on;
proc report data=shoes spanrows;

where region in ('Asia' 'Canada') and product in ('Boot' 'Sandal' 'Slipper');
title 'Ex 1a) COMPUTE BEFORE/AFTER _PAGE_';
column region product sales returns Profit inventory PctInv ;
define region / group;
define product / group;
define profit / computed f=dollar14.;
define pctinv / computed f=percent9.2;
break after region/summarize; 
rbreak after / summarize;

compute pctinv;
profit = sum(sales.sum,-1*returns.sum);
pctinv = sales.sum / inventory.sum;
endcomp;

compute before _page_ / style={background=white just=left
preimage='/caslibs/marketing/&lt;FONT color="#FF0000"&gt;Asia&lt;/FONT&gt;.png?height=4cm&amp;amp;width=6cm'} ; /* should depend on byval */
line ' ';
endcomp;

run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&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/32"&gt;@BrunoMueller&lt;/a&gt; , any idea &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 19:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707736#M217339</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2020-12-22T19:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc report #byval logic for images</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707746#M217343</link>
      <description>Hi:&lt;BR /&gt;  I don't see a BY statement in your code. You actually have 2 BY variables, region and product. Did you mean to have a BY statement in your code?&lt;BR /&gt;Cynthia</description>
      <pubDate>Tue, 22 Dec 2020 20:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707746#M217343</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-12-22T20:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc report #byval logic for images</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707772#M217355</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; That looks like code from my COMPUTE block paper. I do not think you'll be able to dynamically change the preimage file name without using SAS Macro processing. The PROC REPORT code needs to have that value resolved and the preimage value changed either based on a BY variable (which you don't have in your code) or with a Macro variable. You might be able to do it in the Report Writing Interface. I did mock up an example using a SAS macro program -- basically you have to call it one time for every "by" group and then one time for the final Grand Total that would come from the RBREAK:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1608672631422.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52966iF8C60793242E39D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1608672631422.png" alt="Cynthia_sas_0-1608672631422.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I just used clip art for the image for Asia and Canada and then the macro program had only one macro parameter called &amp;amp;WANTREG. I don't have a CAS image to play on right now, so I just used my local install:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro makerep(wantreg=);
proc report data=shoes spanrows;
title1 j=c'Ex 1a) COMPUTE BEFORE/AFTER _PAGE_';
where region = "&amp;amp;wantreg";
column region product sales returns Profit inventory PctInv ;
define region / group;
define product / group;
define profit / computed f=dollar14.;
define pctinv / computed f=percent9.2;
break after region/summarize page; 
 
compute pctinv;
  profit = sum(sales.sum,-1*returns.sum);
  pctinv = sales.sum / inventory.sum;
endcomp;
compute before _page_ / style={background=white just=left 
                               preimage="c:\temp\&amp;amp;wantreg..png?height=4cm&amp;amp;width=6cm"};
  line ' '  ;
endcomp;
run;
%mend makerep;

 
data SHOES;
set SASHELP.SHOES;
where region in ('Asia' 'Canada') and product in ('Boot' 'Sandal' 'Slipper');
run;

proc sort data=shoes;
by region product;
run;

ods pdf file='c:\temp\useimg.pdf';
%makerep(wantreg=Asia);
%makerep(wantreg=Canada);

** Grand Total;
proc report data=shoes spanrows;
column reg prod  sales returns Profit inventory PctInv ;
define reg  / computed 'Region';
define prod  / computed 'Product';
define profit / computed f=dollar14.;
define pctinv / computed f=percent9.2;
compute reg / character length=11;
  reg = 'All Regions';
endcomp;
compute prod / character length=15;
  prod = 'All Products';
endcomp;
compute pctinv;
  profit = sum(sales.sum,-1*returns.sum);
  pctinv = sales.sum / inventory.sum;
endcomp;
run;
ods pdf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 21:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707772#M217355</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-12-22T21:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc report #byval logic for images</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707780#M217359</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're right, I was reading through your paper which was very helpful. &lt;/P&gt;
&lt;P&gt;Actually I found a solution in &lt;A title="proc report dynamic image ref" href="http://de.saswiki.org/images/f/f7/18_KSFE_2014_Wern_-_PROC_REPORT_-_Decathlon.pdf" target="_self"&gt;http://de.saswiki.org/images/f/f7/18_KSFE_2014_Wern_-_PROC_REPORT_-_Decathlon.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here comes the code which is working for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on;
options missing=' ';
proc report data=dna.all spanrows nowd style(report)=[rules=none frame=void linethickness=4 ];
where lowcase(brand) ne "other";

title 'KPI overview';
column logo brand producto  ren fin  kpi ;
define brand / group noprint;
define producto / group ;
define ren / sum;
define fin / sum;
define logo / computed  ;
define kpi / computed f=percent9.1;
break before brand / summarize; 
/* rbreak after / summarize; */

compute kpi;
kpi = ren.sum / fin.sum;
if strip(_break_) not in ("_RBREAK_" "" ) then CALL DEFINE('LOGO','STYLE',"STYLE=
{PREIMAGE='/caslibs/marketing/" ||TRIM(lowcase(brand))|| ".png?height=3cm'}");
endcomp;

run;.&amp;nbsp;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 23:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707780#M217359</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2020-12-22T23:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc report #byval logic for images</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707869#M217417</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've added a do loop functionality.&lt;/P&gt;
&lt;P&gt;Now it works nice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro makerep(wantreg=);
options missing=' ';
%do i=1 %to %sysfunc(countw(&amp;amp;wantreg,%str( )));
%let temp=%scan(&amp;amp;wantreg., %eval(&amp;amp;i));
proc report data=dna.all spanrows nowd style(report)=[rules=none frame=void linethickness=4 ];
where lowcase(brand) =  %unquote(%str(%')&amp;amp;temp%str(%'));

title 'KPI overview';
column brand producto  ren fin  kpi ;
define brand / group noprint;
define producto / group ;
define ren / sum;
define fin / sum;
define kpi / computed f=percent9.1;
break before brand / summarize ; 

compute kpi;
kpi = ren.sum / fin.sum;
endcomp;

compute before _page_ / style={background=white just=left 
preimage="/caslibs/marketing/&amp;amp;temp..png?height=3cm"};
line ' '  ;
endcomp;
run;
%end;
%mend makerep;

options mlogic symbolgen;

%makerep(wantreg=vw audi skoda lcv);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Dec 2020 12:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707869#M217417</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2020-12-23T12:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc report #byval logic for images</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707901#M217434</link>
      <description>Hi, yes, the Macro %DO loop approach is a very efficient technique. I tend to keep my macro examples simple because a lot of folks here in the forums haven't used SAS Macro programming. Good use of %DO to pass the entire string of desired brands.&lt;BR /&gt;Cynthia</description>
      <pubDate>Wed, 23 Dec 2020 15:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-byval-logic-for-images/m-p/707901#M217434</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-12-23T15:29:24Z</dc:date>
    </item>
  </channel>
</rss>

