<?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: Create multiple PNGs using a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818383#M323035</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311553"&gt;@mariko5797&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create file names that have the ID in the file name, and you can create titles that have the ID in the title, all by using a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is documentation on IMAGENAME=&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p0kroq43yu0lspn16hk1u4c65lti.htm#n1tf90icyqmzh9n143tcsn5p44ns" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p0kroq43yu0lspn16hk1u4c65lti.htm#n1tf90icyqmzh9n143tcsn5p44ns&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, the ID can be part of the TITLE when you use by statements&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsglobal/p10gcmrmf83iaxn1ilrx4pra969n.htm#n1sdhrtdplbuosn1sf7wnfiqbasi" target="_self"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsglobal/p10gcmrmf83iaxn1ilrx4pra969n.htm#n1sdhrtdplbuosn1sf7wnfiqbasi&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, again, I think macros are not needed, and the whole thing can be programmed using BY statements.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 16:22:49 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-06-15T16:22:49Z</dc:date>
    <item>
      <title>Create multiple PNGs using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818318#M323009</link>
      <description>&lt;P&gt;I want to loop through all the subject IDs and output a png file for each subject. The run time is fairly short and nothing is being outputted. Is there some sort of statement I am missing? No errors or warnings appear.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 input usubjid $ day mldapcrp mldapcrr psrvqres psrvres fillc @@;
 cards;
 VMP.1	5	6.8	1	7.9	1	1
 VMP.1	6	9.7	1	.	0	2
 VMP.1	7	.	0	8.4	1	3
 VMP.1	8	.	0	.	.	.
 VMP.1	9	.	0	.	0	.
 VMP.1	10	4.3	1	.	0	2
 VMP.2	5	7.3	1	7.9	1	1
 VMP.2	6	4.1	1	.	.	2
 VMP.2	7	3.2	1	6.7	1	1
 VMP.2	8	.	.	.	0	.
 VMP.2	9	.	0	8.3	1	3
 VMP.2	10	5.5	1	.	0	2
 ;
run;

%macro figure();
	ods listing gpath= "&amp;amp;&amp;amp;rptdir.\";
	title; footnote;
	ods escapechar= '^';
	ods graphics on;
	ods graphics / reset= index imagename= "Fig_&amp;amp;id." imagefmt= png;	
	footnote j=c h=12pt bold f= "times new roman" color=red "CONFIDENTIAL";
	title j= center h= 12pt f= "times new roman" bold c= black "&amp;amp;&amp;amp;title. VMP.&amp;amp;id.";

	proc sgplot data= final(where= (usubjid = "VMP.&amp;amp;id."));
	 vbarparm category= day response= fillc / barwidth= 1 colorresponse= fillc
	 	colormodel= (purple red blue) transparency= 0.3 name= 'shade';
	 series x= day y= mldapcrp / legendlabel= "Result 1t" name= "v1" lineattrs= (pattern= 4) y2axis;
	 series x= day y= psrvqres / legendlabel= "Result 2" name= "v2";
	 yaxis label= "Label Y1";
	 y2axis label= "Label Y2";
	 xaxis label= "Study Day";
	 keylegend  / exclude= ("shade");
	run;
 ods graphics off;
%mend figure;

proc sql noprint;
 select distinct usubjid into: idlist separated by ' '
 	from test;
quit;

%put &amp;amp;=idlist;

%macro callreport;
	%do x= 1 %to %sysfunc(countw(&amp;amp;idlist));
	%let id = %scan(&amp;amp;idlist, &amp;amp;x);
	%figure;
	%end;
%mend callreport;

%let title= %str(Comparison, Subject);
%callreport;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.01 seconds
      cpu time            0.03 seconds

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 14:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818318#M323009</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-06-15T14:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple PNGs using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818322#M323010</link>
      <description>&lt;P&gt;Before I try to debug your macro, I point out that it seems as if using a BY statement in your PROC SGPLOT would do what you want without macros. So, please try it with a BY statement in PROC SGPLOT and without a macro.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 14:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818322#M323010</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-15T14:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple PNGs using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818333#M323011</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 input usubjid $ day mldapcrp mldapcrr psrvqres psrvres fillc @@;
 cards;
 VMP.1	5	6.8	1	7.9	1	1
 VMP.1	6	9.7	1	.	0	2
 VMP.1	7	.	0	8.4	1	3
 VMP.1	8	.	0	.	.	.
 VMP.1	9	.	0	.	0	.
 VMP.1	10	4.3	1	.	0	2
 VMP.2	5	7.3	1	7.9	1	1
 VMP.2	6	4.1	1	.	.	2
 VMP.2	7	3.2	1	6.7	1	1
 VMP.2	8	.	.	.	0	.
 VMP.2	9	.	0	8.3	1	3
 VMP.2	10	5.5	1	.	0	2
 ;
run;

%macro figure(id);
	ods listing gpath= "&amp;amp;&amp;amp;rptdir.\";
	title; footnote;
	ods escapechar= '^';
	ods graphics on;
	ods graphics / reset= index imagename= "Fig_&amp;amp;id." imagefmt= png;	
	footnote j=c h=12pt bold f= "times new roman" color=red "CONFIDENTIAL";
	title j= center h= 12pt f= "times new roman" bold c= black "&amp;amp;&amp;amp;title. VMP.&amp;amp;id.";

	proc sgplot data= final(where= (usubjid = "VMP.&amp;amp;id."));
	 vbarparm category= day response= fillc / barwidth= 1 colorresponse= fillc
	 	colormodel= (purple red blue) transparency= 0.3 name= 'shade';
	 series x= day y= mldapcrp / legendlabel= "Result 1t" name= "v1" lineattrs= (pattern= 4) y2axis;
	 series x= day y= psrvqres / legendlabel= "Result 2" name= "v2";
	 yaxis label= "Label Y1";
	 y2axis label= "Label Y2";
	 xaxis label= "Study Day";
	 keylegend  / exclude= ("shade");
	run;
 ods graphics off;
%mend figure;

proc sql noprint;
 select distinct usubjid into: idlist separated by ' '
 	from test;
quit;

%put &amp;amp;=idlist;

%macro callreport;
	%do x= 1 %to %sysfunc(countw(&amp;amp;idlist));
	%let id = %scan(&amp;amp;idlist, &amp;amp;x);
	%figure(&amp;amp;id);
	%end;
%mend callreport;

%let title= %str(Comparison, Subject);
%callreport;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 15:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818333#M323011</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-15T15:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple PNGs using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818343#M323019</link>
      <description>&lt;P&gt;The by statement does output a figure for each id, but is there a way to get it to display each id it is outputting and save it in the file name with this method?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 15:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818343#M323019</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-06-15T15:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple PNGs using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818361#M323029</link>
      <description>&lt;P&gt;The code refers to final and test datasets but only include test.&lt;/P&gt;
&lt;P&gt;There are two &amp;amp;&amp;amp; in front of rptdir macro variable.&lt;/P&gt;
&lt;P&gt;GPATH setting doesn't work properly for me, but I'm using SAS Studio where listing is not the default output. Assuming it works for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tested, this should work, assuming GPATH is fixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
infile cards dlm='09'x;
 input usubjid $ day mldapcrp mldapcrr psrvqres psrvres fillc;
 cards;
 VMP.1	5	6.8	1	7.9	1	1
 VMP.1	6	9.7	1	.	0	2
 VMP.1	7	.	0	8.4	1	3
 VMP.1	8	.	0	.	.	.
 VMP.1	9	.	0	.	0	.
 VMP.1	10	4.3	1	.	0	2
 VMP.2	5	7.3	1	7.9	1	1
 VMP.2	6	4.1	1	.	.	2
 VMP.2	7	3.2	1	6.7	1	1
 VMP.2	8	.	.	.	0	.
 VMP.2	9	.	0	8.3	1	3
 VMP.2	10	5.5	1	.	0	2
 ;
run;


%let rptdir = '/home/fkhurshed/Demo1';

 
%macro figure(id);
	ods listing gpath= "&amp;amp;rptdir./";
	title; footnote;
	ods escapechar= '^';
	ods graphics on;
	ods graphics / reset= index imagename= "Fig_&amp;amp;id." imagefmt= png;	
	footnote j=c h=12pt bold f= "times new roman" color=red "CONFIDENTIAL";
	title j= center h= 12pt f= "times new roman" bold c= black "&amp;amp;&amp;amp;title. VMP.&amp;amp;id.";

	proc sgplot data= final(where= (usubjid = "VMP.&amp;amp;id."));
	 vbarparm category= day response= fillc / barwidth= 1 colorresponse= fillc
	 	colormodel= (purple red blue) transparency= 0.3 name= 'shade';
	 series x= day y= mldapcrp / legendlabel= "Result 1t" name= "v1" lineattrs= (pattern= 4) y2axis;
	 series x= day y= psrvqres / legendlabel= "Result 2" name= "v2";
	 yaxis label= "Label Y1";
	 y2axis label= "Label Y2";
	 xaxis label= "Study Day";
	 keylegend  / exclude= ("shade");
	run;
 ods graphics off;
%mend figure;

proc sql noprint;
 select distinct usubjid into: idlist separated by ' '
 	from final;
quit;

%put &amp;amp;=idlist;

%macro callreport;
	%do x= 1 %to %sysfunc(countw(&amp;amp;idlist));
	%let id = %scan(&amp;amp;idlist, &amp;amp;x);
	%figure(&amp;amp;id);
	%end;
%mend callreport;

%let title= %str(Comparison, Subject);
%callreport;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 15:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818361#M323029</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-15T15:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple PNGs using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818383#M323035</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311553"&gt;@mariko5797&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create file names that have the ID in the file name, and you can create titles that have the ID in the title, all by using a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is documentation on IMAGENAME=&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p0kroq43yu0lspn16hk1u4c65lti.htm#n1tf90icyqmzh9n143tcsn5p44ns" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p0kroq43yu0lspn16hk1u4c65lti.htm#n1tf90icyqmzh9n143tcsn5p44ns&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, the ID can be part of the TITLE when you use by statements&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsglobal/p10gcmrmf83iaxn1ilrx4pra969n.htm#n1sdhrtdplbuosn1sf7wnfiqbasi" target="_self"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsglobal/p10gcmrmf83iaxn1ilrx4pra969n.htm#n1sdhrtdplbuosn1sf7wnfiqbasi&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, again, I think macros are not needed, and the whole thing can be programmed using BY statements.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 16:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-PNGs-using-a-loop/m-p/818383#M323035</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-15T16:22:49Z</dc:date>
    </item>
  </channel>
</rss>

