<?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: conditionally assigning STYLE attributes to a specific column observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863129#M340969</link>
    <description>&lt;P&gt;Here is one way to do the indent. The custom format provides additional blanks for different values. The STYLE={asis=on} overrides the standard behavior of removing leading blanks and the format assignment says to use the format for display so the spaces are available. This approach can require more spaces than you think as proportional fonts can reduce the space used.&lt;/P&gt;
&lt;P&gt;You may &lt;STRONG&gt;not&lt;/STRONG&gt; want the variable Label as an order variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
value $labelindent
"Change_from_Baseline" = "  Change_from_Baseline"
"Female"               = "    Female"
"Male"                 = "    Male"
;
run;

	proc report data= have style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
								 			style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} out=report_scorechange;
		column label N cat1 cat2 cat3;
		define Label/ "" width=25  order=data format= $labelindent. style={asis=on};
		define N/ "Total" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat1/ "Excellent" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat2/ "Good" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat3/ "Fair" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
/*		compute label;*/
/*			if strip(label) eq "Change_from_Baseline" then  call define(_col_, "style", "style=[indent=3 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");*/
/*			else if strip(label) in ("Female", "Male") then  call define(_col_, "style", "style=[indent=6 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");*/
/*			else call define(_col_, "style", "style=[just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");*/
/*		endcomp;*/
	run; 
&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Mar 2023 04:56:56 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-03-09T04:56:56Z</dc:date>
    <item>
      <title>Proc Report: conditionally assigning STYLE attributes to a specific column observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863118#M340964</link>
      <description>&lt;P&gt;Dear Experts,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to output my Proc report results into .xml file using &lt;STRONG&gt;ODS tagsets.excelxp&lt;/STRONG&gt;. Ideally my output table should look like as below (&lt;STRONG&gt;with proper indentation&lt;/STRONG&gt;). However, my code is &lt;U&gt;&lt;EM&gt;producing indentation only for the first occurrence of each value&lt;/EM&gt;&lt;/U&gt;, that is specified in Compute Block (code will be attached below). This also messing up original order of data regardless define/order=data option.&amp;nbsp;&lt;BR /&gt;So, I need your expertise here to figure out how to properly instruct sas for desired outcome.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Label $35; 
input Label $ N cat1 cat2 cat3;
datalines;
Baseline 310 200 100 10
Female 170 . . .
Male 140 . . .
Month8 308 199 99 12
Change_from_Baseline 2 1 1 -2
Female 2 . . .
Male 0 . . .
Month12 304 194 90 20  
Change_from_Baseline 6 6 10 -10
Female 4 . . .
Male 2 . . .
Month16 300 190 85 15
Change_from_Baseline 10 10 15 -5
Female 7 . . .
Male 3 . . .
;
run; 

ods tagsets.excelxp file = "C:\Users\Desktop\test\Score_tables.xml" style=listing
	options(sheet_name= "Table 3 - &lt;FONT color="#00FF00"&gt;&lt;FONT color="#000000"&gt;Categorical&lt;/FONT&gt;"&lt;/FONT&gt; embedded_titles = "on" embedded_footnotes = "on" Merge_Titles_Footnotes = "on" missing_align= 'center' Row_Heights='24,16,0,32,32,0,0' Skip_Space= '0,0,0,1,1');
	proc report data= have style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
								 			style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} out=report_scorechange;
		column label N cat1 cat2 cat3;
		define Label/ "" width=25 order order=data;
		define N/ "Total" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat1/ "Excellent" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat2/ "Good" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat3/ "Fair" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		compute label;
			if strip(label) eq "Change_from_Baseline" then  call define(_col_, "style", "style=[indent=3 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");
			else if strip(label) in ("Female", "Male") then  call define(_col_, "style", "style=[indent=6 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");
			else call define(_col_, "style", "style=[just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");
		endcomp;
	run; 
ods tagsets.excelxp close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Expected Result" style="width: 582px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81239iFA033EF0EC8983BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Expected Result" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Expected Result&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 03:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863118#M340964</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-03-09T03:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report: conditionally assigning STYLE attributes to a specific column observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863129#M340969</link>
      <description>&lt;P&gt;Here is one way to do the indent. The custom format provides additional blanks for different values. The STYLE={asis=on} overrides the standard behavior of removing leading blanks and the format assignment says to use the format for display so the spaces are available. This approach can require more spaces than you think as proportional fonts can reduce the space used.&lt;/P&gt;
&lt;P&gt;You may &lt;STRONG&gt;not&lt;/STRONG&gt; want the variable Label as an order variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
value $labelindent
"Change_from_Baseline" = "  Change_from_Baseline"
"Female"               = "    Female"
"Male"                 = "    Male"
;
run;

	proc report data= have style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
								 			style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} out=report_scorechange;
		column label N cat1 cat2 cat3;
		define Label/ "" width=25  order=data format= $labelindent. style={asis=on};
		define N/ "Total" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat1/ "Excellent" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat2/ "Good" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat3/ "Fair" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
/*		compute label;*/
/*			if strip(label) eq "Change_from_Baseline" then  call define(_col_, "style", "style=[indent=3 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");*/
/*			else if strip(label) in ("Female", "Male") then  call define(_col_, "style", "style=[indent=6 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");*/
/*			else call define(_col_, "style", "style=[just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");*/
/*		endcomp;*/
	run; 
&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2023 04:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863129#M340969</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-09T04:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report: conditionally assigning STYLE attributes to a specific column observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863193#M340995</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;, proc format might change data format in other destinations like html, but it seems to have no influence over .xml outputs.&lt;/P&gt;
&lt;P&gt;Recently,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/219687"&gt;@IyenJ&lt;/a&gt;&amp;nbsp; helped me with formatting .xml cells&amp;nbsp;using "&lt;SPAN&gt;Style(column)={TAGATTR='format:0.00'}" (&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-Report-to-ODS-EXCEL-xml-issue-in-writing-last-0-after-the/td-p/859800" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Proc-Report-to-ODS-EXCEL-xml-issue-in-writing-last-0-after-the/td-p/859800&lt;/A&gt;).&amp;nbsp;&lt;BR /&gt;Based on your suggestion and above experience I've tried to use {tagattr= "format: $labelindent."}. This creates output in Results window without format, but not creating any .xml output.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods tagsets.excelxp file = "C:\Users\Desktop\test\Score_tables.xml" style=listing
	options(sheet_name= "Table 3 - Categorical" embedded_titles = "on" embedded_footnotes = "on" Merge_Titles_Footnotes = "on" missing_align= 'center' Row_Heights='24,16,0,32,32,0,0' Skip_Space= '0,0,0,1,1');
	proc report data= have style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
								 			style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} out=report_scorechange;
		column label N cat1 cat2 cat3;
		define Label/ "" width=25 style(column)= {just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt &lt;U&gt;&lt;STRONG&gt;TAGATTR='format: $labelindent.'&lt;/STRONG&gt;&lt;/U&gt;} display;
		define N/ "Total" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat1/ "Excellent" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat2/ "Good" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat3/ "Fair" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
	run; 
ods tagsets.excelxp close;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2023 14:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/863193#M340995</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-03-09T14:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report: conditionally assigning STYLE attributes to a specific column observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/864126#M341282</link>
      <description>&lt;P&gt;Dear Community,&amp;nbsp;&lt;BR /&gt;Just wanted to follow up on this question as I received the solution from SAS Tech Support Team.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution was pretty simple -&lt;U&gt;&lt;EM&gt; adding an extra numeric variable&lt;/EM&gt;&lt;/U&gt; to the dataset HAVE (&lt;STRONG&gt;order=_n_&lt;/STRONG&gt;) then &lt;U&gt;&lt;EM&gt;define this variable in proc report as internal ordering variable&lt;/EM&gt;&lt;/U&gt; (&lt;STRONG&gt;define order / order order=internal noprint&lt;/STRONG&gt;;).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;The full code is below:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	set have;
	&lt;FONT face="arial black,avant garde"&gt;order=_n_;&lt;/FONT&gt;
run;

ods tagsets.excelxp file = "C:\Users\Desktop\test\Score_tables.xml" style=listing
	options(sheet_name= "Table 3 - Categorical" embedded_titles = "on" embedded_footnotes = "on" Merge_Titles_Footnotes = "on" missing_align= 'center' Row_Heights='24,16,0,32,32,0,0' Skip_Space= '0,0,0,1,1');
	proc report data= have style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
							style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} ;
		column &lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt;order&lt;/STRONG&gt; &lt;/FONT&gt;label N cat1 cat2 cat3;
		&lt;FONT face="arial black,avant garde"&gt;define order / order order=internal noprint;&lt;/FONT&gt;
		define Label/ " " width=25 order ;
		define N/ "Total" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat1/ "Excellent" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat2/ "Good" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define cat3/ "Fair" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
			compute label;
				if strip(label) eq "Change_from_Baseline" then  call define(_col_, "style", "style=[indent=3 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");
				else if strip(label) in ("Female", "Male") then call define(_col_, "style", "style=[indent=6 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");
				else call define(_col_, "style", "style=[just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt]");
			endcomp;
	run;
ods tagsets.excelxp close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The obtained result is:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="abdulatif_0-1678818458923.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81536i6A2889FA2B0F430C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="abdulatif_0-1678818458923.png" alt="abdulatif_0-1678818458923.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this will be helpful to others too.&amp;nbsp;&lt;BR /&gt;Thank you, all, for taking time to answer the question!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 18:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-conditionally-assigning-STYLE-attributes-to-a/m-p/864126#M341282</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-03-14T18:27:50Z</dc:date>
    </item>
  </channel>
</rss>

