<?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: Iterative DO Loop for multiple pages in pdf in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/823078#M325008</link>
    <description>Alright, I have found something that works for me. I simply put an macro variable (%Let Variable) and then use the scan function, to read the variables one by one :&lt;BR /&gt;%Let Var1to100 = Var1 Var2 ... Var100&lt;BR /&gt;%do i % to 100)&lt;BR /&gt;%Let Variable = SCAN(&amp;amp;Var1to100, &amp;amp;i)&lt;BR /&gt;</description>
    <pubDate>Wed, 13 Jul 2022 10:03:54 GMT</pubDate>
    <dc:creator>_Manhattan</dc:creator>
    <dc:date>2022-07-13T10:03:54Z</dc:date>
    <item>
      <title>Iterative DO Loop for multiple pages in pdf</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/822238#M324679</link>
      <description>&lt;P&gt;Hey folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am interested in writing a do loop, that uses information out of a SAS Table and puts that information together with a .jpg into a pdf. The data I am working with looks more or less like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ExSASTable.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73054i09D8726513C6FDD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ExSASTable.PNG" alt="ExSASTable.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, I would like to extract all rows one by one in the table and merge it together with a .jpg. So the outcome should look like the attached pdf. I also attached some example data in an xlsx file. The code I have got so far looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let i = 1;
%do i = 1 to 3;
%let as = Var1 Var2 Var3;
data reduced;
set ExEXc;
if item = "&amp;amp;as"; 
run;

ods pdf file="J:\Learning SAS\Test.pdf";
ods layout start width = 19cm height = 28cm ; 
ods region y=3cm x=0.4cm;
proc report data=reduced;
run;
ods region y=6cm x=3cm width=13cm height=8cm style={backgroundimage="J:/Variables/&amp;amp;as.jpg" };
ods text= " ";
ods layout end;
ods pdf close;
%let i = &amp;amp;i + 1;
%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As you can see in the second ods region statement, I am refering to a folder that contains the .jpg files thats looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Example Pic.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73055i992CFDEE4665A87C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Example Pic.PNG" alt="Example Pic.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Ideally, my &amp;amp;as macro Variable contains the Variables and the .jpg files altogether so the code is a as simple as possible. I am not able to attach .jpg files, but it really doesnt matter which pictures are used as long as they got the same name as the Variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To conclude: As I am just getting used to macro coding, I was wondering if any of you knows how to specify the DO Loop, so that it reads the &lt;STRONG&gt;first line&lt;/STRONG&gt; of my data and merges it together with the &lt;STRONG&gt;matching first .jpg file&lt;/STRONG&gt;, puts it together on &lt;STRONG&gt;page one&lt;/STRONG&gt; of the pdf and continues with selecting the &lt;STRONG&gt;next line of the data&lt;/STRONG&gt;, the &lt;STRONG&gt;next .jpg file&lt;/STRONG&gt;, puts it on the &lt;STRONG&gt;second page&lt;/STRONG&gt; of the pdf and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jakob&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 11:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/822238#M324679</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2022-07-08T11:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative DO Loop for multiple pages in pdf</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/822302#M324711</link>
      <description>&lt;P&gt;Here's something that worked for me. Part of your issue was that you weren't putting your code inside a %macro/%mend. I created a macro I called "doSomething" within %macro/%mend statements. I only used 2 variable values: Var1 and Var2, but I think you get the general idea, I hope.&lt;/P&gt;&lt;PRE&gt;data ExEXc;
  input Variable $ Mean SD;
  datalines;
  Var1 2 0.67
  Var2 3 0.43
; run;

%macro doSomething();
	%let Var1 = Var1;
	%let Var2 = Var2;
	%let Pic1 = c:\temp\pic1.jpg;
	%let Pic2 = c:\temp\pic2.jpg;
	
	ods pdf file="C:\temp\Test.pdf" notoc startpage=no;

	%do i=1 %to 2;
		ods layout start width = 19cm height = 28cm ; 
		ods region y=3cm x=0.4cm;
		proc report data=ExEXc;
			where variable = "&amp;amp;&amp;amp;Var&amp;amp;i";
		run;
		ods region y=6cm x=3cm width=13cm height=8cm style={backgroundimage="&amp;amp;&amp;amp;Pic&amp;amp;i" };
		ods text= " ";
		ods layout end;
		ods startpage=now;
	%end;
	
	ods pdf close;

%mend;

%doSomething();&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jul 2022 15:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/822302#M324711</guid>
      <dc:creator>bnawrocki</dc:creator>
      <dc:date>2022-07-08T15:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative DO Loop for multiple pages in pdf</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/822771#M324882</link>
      <description>Hey bnawrocki,&lt;BR /&gt;&lt;BR /&gt;thank you a lot for your help! It somehow works for me, but not quite as intended. I guess the main difficulty lays in automatising the variables and pictures. Within your example for e.g. 100 Variables and 100 Pics, I would need to define all of them in the %let Statements wouldn't I?&lt;BR /&gt;So it would look something like this:&lt;BR /&gt;%let var1 = var1&lt;BR /&gt;%let var2 = var2&lt;BR /&gt;...&lt;BR /&gt;%let var100 = var100&lt;BR /&gt;and the same with the pics:&lt;BR /&gt;%let pic1 = pic1.jpg&lt;BR /&gt;%let pic2.jpg = pic2.jpg&lt;BR /&gt;...&lt;BR /&gt;%let pic100 = pic100.jpg&lt;BR /&gt;&lt;BR /&gt;I would like to include all of them in one let statement. Furthermore, the variables and pics dont always have the structure of var"1" pic"1" etc. they look more like "XYZ3461" "XYZ2345". So I am not even sure, if the whole Do Loop with i=1 to X works for me. I do not know if there is any other way of doing this. So far I have not come up with anything else. Do you have any Idea?&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Jakob</description>
      <pubDate>Tue, 12 Jul 2022 07:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/822771#M324882</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2022-07-12T07:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative DO Loop for multiple pages in pdf</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/823078#M325008</link>
      <description>Alright, I have found something that works for me. I simply put an macro variable (%Let Variable) and then use the scan function, to read the variables one by one :&lt;BR /&gt;%Let Var1to100 = Var1 Var2 ... Var100&lt;BR /&gt;%do i % to 100)&lt;BR /&gt;%Let Variable = SCAN(&amp;amp;Var1to100, &amp;amp;i)&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Jul 2022 10:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-DO-Loop-for-multiple-pages-in-pdf/m-p/823078#M325008</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2022-07-13T10:03:54Z</dc:date>
    </item>
  </channel>
</rss>

