<?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 Proc report conditional fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-conditional-fields/m-p/843463#M333464</link>
    <description>&lt;PRE&gt;data cars(keep=make model origin weight);
set sashelp.cars;
run;

data cars1(keep=make model);
set cars;
run;

data cars2(keep=make model origin);
set cars;
run;

data cars3(keep=make model origin weight);
set cars;
run;


%let colstyle70  = style(column)={just=left cellwidth=70pt};
%let colstyle90  = style(column)={just=left cellwidth=90pt};

%macro Final(final,sheet_nm);				
				
ODS TAGSETS.ExcelXP				
   options(sheet_interval='none'				
           absolute_column_width='8'				
           sheet_name=&amp;amp;sheet_nm.				
           center_horizontal="no"				
           Orientation='Landscape'				
           embedded_titles='No'				
           fittopage="No"				
           blackandwhite="No"
		   auto_filter = "Yes"	
           Embedded_Footnotes='Yes'				
           autofit_height="Yes");				
				
%NoAccountLogic(&amp;amp;final.,&amp;amp;ReportName);				
		PROC REPORT DATA=&amp;amp;final. headskip split='*' wrap nowd ;

columns make model origin weight ;

Define make     / &amp;amp;colstyle90 "Make";
Define model     / &amp;amp;colstyle90 "Model";
Define origin     / &amp;amp;colstyle90 "Origin";
Define weight     / &amp;amp;colstyle90 "Weight";

run;

%mend final;				
				
%Final(cars1,"Cars1");	
%Final(cars2,"Cars2");	
%Final(cars3,"Cars3");	

 

&lt;/PRE&gt;
&lt;P&gt;I have 3 datasets with the same fields.&amp;nbsp; I want the output to be conditional based on the dataset contents.&amp;nbsp; Note the changes in fields per cars1,2 and 3.&amp;nbsp; Is there a way to do this in ods without repeating each ods output and fields separately?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2022 20:27:13 GMT</pubDate>
    <dc:creator>Q1983</dc:creator>
    <dc:date>2022-11-09T20:27:13Z</dc:date>
    <item>
      <title>Proc report conditional fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-conditional-fields/m-p/843463#M333464</link>
      <description>&lt;PRE&gt;data cars(keep=make model origin weight);
set sashelp.cars;
run;

data cars1(keep=make model);
set cars;
run;

data cars2(keep=make model origin);
set cars;
run;

data cars3(keep=make model origin weight);
set cars;
run;


%let colstyle70  = style(column)={just=left cellwidth=70pt};
%let colstyle90  = style(column)={just=left cellwidth=90pt};

%macro Final(final,sheet_nm);				
				
ODS TAGSETS.ExcelXP				
   options(sheet_interval='none'				
           absolute_column_width='8'				
           sheet_name=&amp;amp;sheet_nm.				
           center_horizontal="no"				
           Orientation='Landscape'				
           embedded_titles='No'				
           fittopage="No"				
           blackandwhite="No"
		   auto_filter = "Yes"	
           Embedded_Footnotes='Yes'				
           autofit_height="Yes");				
				
%NoAccountLogic(&amp;amp;final.,&amp;amp;ReportName);				
		PROC REPORT DATA=&amp;amp;final. headskip split='*' wrap nowd ;

columns make model origin weight ;

Define make     / &amp;amp;colstyle90 "Make";
Define model     / &amp;amp;colstyle90 "Model";
Define origin     / &amp;amp;colstyle90 "Origin";
Define weight     / &amp;amp;colstyle90 "Weight";

run;

%mend final;				
				
%Final(cars1,"Cars1");	
%Final(cars2,"Cars2");	
%Final(cars3,"Cars3");	

 

&lt;/PRE&gt;
&lt;P&gt;I have 3 datasets with the same fields.&amp;nbsp; I want the output to be conditional based on the dataset contents.&amp;nbsp; Note the changes in fields per cars1,2 and 3.&amp;nbsp; Is there a way to do this in ods without repeating each ods output and fields separately?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-conditional-fields/m-p/843463#M333464</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2022-11-09T20:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report conditional fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-conditional-fields/m-p/843473#M333466</link>
      <description>&lt;P&gt;Since you are doing this in a macro where you pass a parameter with a macro variable holding the name of the set use a single macro variable holding values you are assigning to colstyle70 and colstyle90 conditionally&amp;nbsp; based on the value of the parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like the following: (Caution: that = is going to be case sensitive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;final=cars1 %then %let colstyle= style(column)={just=left cellwidth=70pt};&lt;/P&gt;
&lt;P&gt;%else %if &amp;amp;final=cars2 %then %let colstyle= style(column)={just=left cellwidth=90pt};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And use a proc report like&lt;/P&gt;
&lt;PRE&gt;Proc report data=&amp;amp;final. headskip split='*' wrap nowd
   &amp;amp;colstyle
;
run;&lt;/PRE&gt;
&lt;P&gt;If you do not provide a COLUMNS statement all the variables will be output by default and the style applied to all columns.&lt;/P&gt;
&lt;P&gt;If you need to set per column different style attributes that differ for the same variable in multiple sets then perhaps the macro language isn't worth it. You can spend a lot of time getting one combination to work and then have to start all over for the next. At which point you could have written a custom Proc Report for each faster.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-conditional-fields/m-p/843473#M333466</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-09T20:58:49Z</dc:date>
    </item>
  </channel>
</rss>

