<?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 Changing proc report column label dynamically? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698092#M79829</link>
    <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there is a way of dynamically changing the label of proc report column label, using call define or otherwise? Please consider the below example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars_unit;
	set sashelp.cars;
	length Unit $5;

	if Origin EQ "Europe" then
		Unit = "kW";
	else Unit = "hp";
run;

proc sort data=cars_unit;
	by Origin;

proc report data=cars_unit;
	by Origin;
	columns Make Horsepower, (mean std);
	define make / group;
	define Horsepower / "Horsepower [hp]" analysis;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to have the label say "Horsepower [kW]" if the Origin is Europe. I could probably to achieve the desired goal using macros but I was wondering if it can be done using proc report alone. Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2020 07:45:24 GMT</pubDate>
    <dc:creator>js5</dc:creator>
    <dc:date>2020-11-11T07:45:24Z</dc:date>
    <item>
      <title>Changing proc report column label dynamically?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698092#M79829</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there is a way of dynamically changing the label of proc report column label, using call define or otherwise? Please consider the below example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars_unit;
	set sashelp.cars;
	length Unit $5;

	if Origin EQ "Europe" then
		Unit = "kW";
	else Unit = "hp";
run;

proc sort data=cars_unit;
	by Origin;

proc report data=cars_unit;
	by Origin;
	columns Make Horsepower, (mean std);
	define make / group;
	define Horsepower / "Horsepower [hp]" analysis;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to have the label say "Horsepower [kW]" if the Origin is Europe. I could probably to achieve the desired goal using macros but I was wondering if it can be done using proc report alone. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 07:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698092#M79829</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2020-11-11T07:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Changing proc report column label dynamically?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698125#M79830</link>
      <description>Print it one by one .&lt;BR /&gt;&lt;BR /&gt;proc report data=cars_unit;&lt;BR /&gt;	where Origin='USA';&lt;BR /&gt;	columns Make Horsepower, (mean std);&lt;BR /&gt;	define make / group;&lt;BR /&gt;	define Horsepower / "Horsepower [hp]" analysis;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc report data=cars_unit;&lt;BR /&gt;	where Origin='EURO';&lt;BR /&gt;	columns Make Horsepower, (mean std);&lt;BR /&gt;	define make / group;&lt;BR /&gt;	define Horsepower / "Horsepower [kW]" analysis;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 11 Nov 2020 11:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698125#M79830</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-11-11T11:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Changing proc report column label dynamically?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698628#M79831</link>
      <description>&lt;P&gt;This would work, but would not be that different to the macro solution I was hoping to avoid. So there is no way of solving this using compute/call define?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 11:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698628#M79831</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2020-11-13T11:54:54Z</dc:date>
    </item>
    <item>
      <title>get Re: Changing proc report column label dynamically?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698630#M79832</link>
      <description>&lt;P&gt;You may get it by LINE , but I am not sure that if style is what you want to see?&lt;/P&gt;
&lt;P&gt;Or&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp; maybe have a good idea.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 12:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698630#M79832</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-11-13T12:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Changing proc report column label dynamically?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698634#M79833</link>
      <description>&lt;P&gt;You can not change the label dynamically.&lt;/P&gt;
&lt;P&gt;Things that change dynamically will have to be data.&lt;/P&gt;
&lt;P&gt;ACROSS is used to place data values in the column header area of the report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Q: So what to change in data transformation ?&lt;/P&gt;
&lt;P&gt;A: The unit&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of unit being only 'hp' or 'Kw', make it 'Power (hp)' or 'Power (kW)'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 1:1 association you are forcing between origin and power unit allow you to use unit as ACROSS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data cars_unit;
  set sashelp.cars;
  length Unit $15;

  if Origin EQ "Europe" then do;
    Unit = "Power (kW)";
    Power = horsepower / 1.34102209;
  end;
  else do;
    Unit = "Power (hp)";
    Power = horsepower;
  end;

  keep origin make power unit;
run;

proc sort data=cars_unit;
  by Origin;

ods html file='cars.html' style=plateau;

proc report data=cars_unit;
  by Origin;
  columns Make unit,power,(mean std);
  define make / group;
  define unit / ' ' across;
  define Power / ' ' analysis;

  where make in: ('A','B','C','D','L');
run;

ods html close;&lt;/PRE&gt;
&lt;P&gt;Output image&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_0-1605269883632.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51632iA83C7BFE5FE317AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardADeVenezia_0-1605269883632.png" alt="RichardADeVenezia_0-1605269883632.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditorRichardADeVenezia_4" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 12:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698634#M79833</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-11-13T12:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Changing proc report column label dynamically?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698640#M79834</link>
      <description>This is exactly what I was looking for, thanks!</description>
      <pubDate>Fri, 13 Nov 2020 13:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Changing-proc-report-column-label-dynamically/m-p/698640#M79834</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2020-11-13T13:26:52Z</dc:date>
    </item>
  </channel>
</rss>

