<?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: How to apply the variable value to all proc reports in a program to create individual files. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527224#M143692</link>
    <description>Thank You! Worked like a charm! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Tue, 15 Jan 2019 06:35:43 GMT</pubDate>
    <dc:creator>mandonium</dc:creator>
    <dc:date>2019-01-15T06:35:43Z</dc:date>
    <item>
      <title>How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527126#M143647</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm creating subject profiles and I want to know how to apply the subject (patient) id into all proc reports in one ODS pdf output.&amp;nbsp; Right now there are only 20 subjects and I manually enter them at the top (highlighted in &lt;FONT color="#FF00FF"&gt;pink&lt;/FONT&gt;) to make one sas program for all subjects.&amp;nbsp; I would like to have one program to run all subject profiles.&amp;nbsp; I did make a global program that runs all the individual subject profiles, but this study is growing and I would like something simplier.&amp;nbsp; Any help is greatly appreciated.&amp;nbsp; Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ptno = &lt;FONT color="#FF00FF"&gt;018 -1007&lt;/FONT&gt;;

%let subj = where patient="&amp;amp;ptno";

goptions device=actximg;

ods listing close;
options orientation=landscape;
ods pdf file="&amp;amp;path_out\patient profiles_&lt;FONT color="#FF00FF"&gt;018-1007&lt;/FONT&gt;_&amp;amp;rundate..pdf" style=conatus;

proc report data=ae01 nowd headskip split='\';
	title4 height=10pt justify=left "Subject &amp;amp;ptno" height=10pt justify=center 'Adverse Events';
	column	patient aeno path aeterm aestdat aesttim aeendat aeentim aeser_display aesev_display 
		aerel1_display aerel2_display aeacn3_display aeacnoth_display aeout_display;
	&amp;amp;subj;
	define	patient /			style=[just=c vjust=t cellwidth=20mm]	display "Subject ID" ;
	define	aeno /				order noprint;
	define	path /				style=[just=l vjust=t cellwidth=20mm]	display "Path";
	define	aeterm /			style=[just=l vjust=t cellwidth=50mm]	order id;
	define	aestdat /			style=[just=c vjust=t cellwidth=25mm] page;
	define	aesttim /			style=[just=c vjust=t cellwidth=25mm];
	define	aeendat /			style=[just=c vjust=t cellwidth=25mm];
	define	aeentim /			style=[just=c vjust=t cellwidth=25mm];
	define  aeser_display /		style=[just=c vjust=t cellwidth=25mm]	display "Serious AE\ (SAE)" page;
	define	aesev_display /		style=[just=l vjust=t cellwidth=25mm]	display "Severity";
	define	aerel1_display /	style=[just=l vjust=t cellwidth=25mm]	display "Relationship\ to Toca 511";
	define	aerel2_display /	style=[just=l vjust=t cellwidth=25mm]	display "Relationship\ to Toca FC";
	define	aeacn3_display /	style=[just=l vjust=t cellwidth=45mm]	display "Action Taken\ to Treat Event" page;
	define	aeacnoth_display /	style=[just=l vjust=t cellwidth=45mm]	display "Other, Action Taken";
	define	aeout_display /		style=[just=l vjust=t cellwidth=50mm]	display "Outcome";
run;

proc report data=toc6.ae1a nowd headskip split='\';
	title4 height=10pt justify=left "Subject &amp;amp;ptno" height=10pt justify=center 'Adverse Events - Fever';
	column	patient path ae1stdat ae1sttim ae1endat ae1entim ae1yn1_display ae1res2_display ae1resu2_display
			ae1et_display ae1etoth_display;
	&amp;amp;subj;
	define	patient /			style=[just=c vjust=t cellwidth=20mm]	display "Subject ID" ;
	define	path /				style=[just=l vjust=t cellwidth=20mm]	display "Path" order id;
	define	ae1stdat /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1sttim /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1endat /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1entim /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1yn1_display /	style=[just=l vjust=t cellwidth=25mm]	display "Patient's Temperature Recorded?";
	define	ae1res2_display /	style=[just=l vjust=t cellwidth=25mm]	display "Highest Temperature Start to End";
	define	ae1resu2_display /	style=[just=l vjust=t cellwidth=25mm]	display "Unit";
	define	ae1et_display /		style=[just=l vjust=t cellwidth=50mm]	display "Etiology";
	define	ae1etoth_display /	style=[just=l vjust=t cellwidth=50mm];
run;&lt;BR /&gt;&lt;BR /&gt;ods pdf close;&lt;BR /&gt;&lt;BR /&gt;ods listing;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Jan 2019 21:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527126#M143647</guid>
      <dc:creator>mandonium</dc:creator>
      <dc:date>2019-01-14T21:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527133#M143650</link>
      <description>&lt;P&gt;If the results for each patient have to be in individual PDF files, then you have to write a loop that loops through all possible patients.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/**** UNTESTED CODE ****/
%macro dothis;
proc sql noprint;
    select distinct patient into :patients separated by '~' from ae01;
quit;


%do i=1 %to &amp;amp;sqlobs;
    %let this_patient = %scan(&amp;amp;patients,&amp;amp;i,~);
    ods pdf file="&amp;amp;path_out\patient profiles_&amp;amp;this_patient._&amp;amp;rundate..pdf"
        style=conatus;
    proc report data=ae01(where=(patient="&amp;amp;this_patient")) nowd headskip ...;
    ...
    run;
    ods pdf close;
%end;
%mend;
%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 21:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527133#M143650</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-14T21:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527137#M143653</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First put the code in a macro and then apply on the varying parameter. You can create a list of parameters and then can call the macro using call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example (not tested);&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro Pt_report(ptno);
goptions device=actximg;

ods listing close;
options orientation=landscape;
ods pdf file="&amp;amp;path_out\patient profiles_&amp;amp;ptno_&amp;amp;rundate..pdf" style=conatus;

proc report data=ae01 nowd headskip split='\';
	title4 height=10pt justify=left "Subject &amp;amp;ptno" height=10pt justify=center 'Adverse Events';
	column	patient aeno path aeterm aestdat aesttim aeendat aeentim aeser_display aesev_display 
		aerel1_display aerel2_display aeacn3_display aeacnoth_display aeout_display;
	where patient="&amp;amp;ptno";
	define	patient /			style=[just=c vjust=t cellwidth=20mm]	display "Subject ID" ;
	define	aeno /				order noprint;
	define	path /				style=[just=l vjust=t cellwidth=20mm]	display "Path";
	define	aeterm /			style=[just=l vjust=t cellwidth=50mm]	order id;
	define	aestdat /			style=[just=c vjust=t cellwidth=25mm] page;
	define	aesttim /			style=[just=c vjust=t cellwidth=25mm];
	define	aeendat /			style=[just=c vjust=t cellwidth=25mm];
	define	aeentim /			style=[just=c vjust=t cellwidth=25mm];
	define  aeser_display /		style=[just=c vjust=t cellwidth=25mm]	display "Serious AE\ (SAE)" page;
	define	aesev_display /		style=[just=l vjust=t cellwidth=25mm]	display "Severity";
	define	aerel1_display /	style=[just=l vjust=t cellwidth=25mm]	display "Relationship\ to Toca 511";
	define	aerel2_display /	style=[just=l vjust=t cellwidth=25mm]	display "Relationship\ to Toca FC";
	define	aeacn3_display /	style=[just=l vjust=t cellwidth=45mm]	display "Action Taken\ to Treat Event" page;
	define	aeacnoth_display /	style=[just=l vjust=t cellwidth=45mm]	display "Other, Action Taken";
	define	aeout_display /		style=[just=l vjust=t cellwidth=50mm]	display "Outcome";
run;

proc report data=toc6.ae1a nowd headskip split='\';
	title4 height=10pt justify=left "Subject &amp;amp;ptno" height=10pt justify=center 'Adverse Events - Fever';
	column	patient path ae1stdat ae1sttim ae1endat ae1entim ae1yn1_display ae1res2_display ae1resu2_display
			ae1et_display ae1etoth_display;
	where patient="&amp;amp;ptno";
	define	patient /			style=[just=c vjust=t cellwidth=20mm]	display "Subject ID" ;
	define	path /				style=[just=l vjust=t cellwidth=20mm]	display "Path" order id;
	define	ae1stdat /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1sttim /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1endat /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1entim /			style=[just=c vjust=t cellwidth=25mm];
	define	ae1yn1_display /	style=[just=l vjust=t cellwidth=25mm]	display "Patient's Temperature Recorded?";
	define	ae1res2_display /	style=[just=l vjust=t cellwidth=25mm]	display "Highest Temperature Start to End";
	define	ae1resu2_display /	style=[just=l vjust=t cellwidth=25mm]	display "Unit";
	define	ae1et_display /		style=[just=l vjust=t cellwidth=50mm]	display "Etiology";
	define	ae1etoth_display /	style=[just=l vjust=t cellwidth=50mm];
run;ods pdf close;ods listing;

%Mend pt_report;

proc sql;
create table ptno_for_run as
select distinct ptno from have;
quit;

data _null_;
set ptno_for_run;
Call Execute(cats('%pt_report(',Strip(ptno),');'));
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jan 2019 14:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527137#M143653</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-01-15T14:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527157#M143661</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;SPAN&gt;Suryakiran,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I changed the ptno to patient because that's the variable name.&amp;nbsp; I run the updated program and got this message:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sascode01.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26273iE8851726CC1C88D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="sascode01.JPG" alt="sascode01.JPG" /&gt;&lt;/span&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 21:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527157#M143661</guid>
      <dc:creator>mandonium</dc:creator>
      <dc:date>2019-01-14T21:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527179#M143675</link>
      <description>&lt;P&gt;Poste code and errors into a code box instead of a picture. Use the forum's {I} icon to open the box. Then just copy and paste from the log. Best is to include as a minimum an entire data step or procedure call. Some errors are actually caused by something on a previous line and the line reported with an error may not contain the actual reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also with text of the code we can edit the text to show what is needed instead of having to type a description like: it looks like you are missing a comma following the "strip(patient)" part of your code.&lt;/P&gt;
&lt;P&gt;You don't need to use strip with CATS. Note from&amp;nbsp;the documentation:&lt;/P&gt;
&lt;H1 class="xis-title" id="n1e21rr6al5m2nn19r1fat5qxwrt"&gt;&lt;A name="~1" target="_blank"&gt;&lt;/A&gt;&lt;FONT style="background-color: rgb(252, 222, 192);"&gt;CATS&lt;/FONT&gt; Function&lt;/H1&gt;
&lt;P class="xis-shortDescription"&gt;Removes leading and trailing blanks, and returns a concatenated character string.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 23:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527179#M143675</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-14T23:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527186#M143678</link>
      <description>I used the code box first but the red underline was not in the same position. That's why I chose to capture a screen shot instead.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help. I will make the change and let you know what happens.</description>
      <pubDate>Mon, 14 Jan 2019 23:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527186#M143678</guid>
      <dc:creator>mandonium</dc:creator>
      <dc:date>2019-01-14T23:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the variable value to all proc reports in a program to create individual files.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527224#M143692</link>
      <description>Thank You! Worked like a charm! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 15 Jan 2019 06:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-variable-value-to-all-proc-reports-in-a-program/m-p/527224#M143692</guid>
      <dc:creator>mandonium</dc:creator>
      <dc:date>2019-01-15T06:35:43Z</dc:date>
    </item>
  </channel>
</rss>

