<?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: Naming a variable after a Proc Transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478493#M123400</link>
    <description>&lt;P&gt;I'm not sure what you mean with the transpose?&lt;BR /&gt;PROC TRANSPOSE has both the ID and IDLABEL to allow you to dynamically name the fields, but it seems yours would translate directly. Did you try PROC TRANSPOSE and it didn't work somehow? If so, please post the code and an example of your input data and we can advise you on how it should be structured.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jul 2018 21:37:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-07-16T21:37:03Z</dc:date>
    <item>
      <title>Naming a variable after a Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478491#M123399</link>
      <description>&lt;P&gt;I have a project that produces a sgplot and it works great.&amp;nbsp; However, I'd like to write the code to be able to handle changes in the FISC_YEAR_NBR_LABEL column because over time the dates will auto change based on the day/month/year. The proc report was written with the&amp;nbsp;&lt;SPAN&gt;FISC_YEAR_NBR_LABEL hard coded (see code section).&amp;nbsp; The question is how do I write code to label these with generic variable names then have a method to auto name in the report code after a Proc Transpose? Or other suggestions on how to do this so that I don't have to edit the hard code every year.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;YoY Comparison&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;FY18&lt;/TD&gt;&lt;TD&gt;FY18YTD&lt;/TD&gt;&lt;TD&gt;FY19YTD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;TD&gt;750&lt;/TD&gt;&lt;TD&gt;532 (colored green)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;490&lt;/TD&gt;&lt;TD&gt;490&lt;/TD&gt;&lt;TD&gt;380 (colored green)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;proc report data=WORK.Add_UPdated_Thru nowd nocenter
	style(header) = [background=white color=black frame=void]
	style(column header) = [background=white color=black frame=void rules=none height=12]
	style(report) = [rules=none frame=void cellspacing=15 background=white];
	col ('YoY Comparison' Label FY18 FY18YTD FY19YTD);
	define Label / ' ';
	define FY18 / display;
	define FY18YTD / display;
	define FY19YTD / display;

	compute FY19YTD;

		if FY18YTD &amp;gt; FY19YTD then
			call define (_col_,"style","style={background=mogy}");

		if FY18YTD &amp;lt; FY19YTD then
			call define (_col_,"style","style={background=lightred}");

		if FY18YTD = FY19YTD then
			call define (_col_,"style","style={background=yellow}");
	endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data tables before Proc Transpose and after.&amp;nbsp; Afterwards, the values for the FISC_YEAR_NBR_LABEL become the headers as in the lower chart.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;FISC_YEAR_NBR_LABEL&lt;/TD&gt;&lt;TD&gt;AvgDaily&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;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TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;FY18&lt;/TD&gt;&lt;TD&gt;FY18YTD&lt;/TD&gt;&lt;TD&gt;FY19YTD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;TD&gt;750&lt;/TD&gt;&lt;TD&gt;532&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;490&lt;/TD&gt;&lt;TD&gt;490&lt;/TD&gt;&lt;TD&gt;380&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 21:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478491#M123399</guid>
      <dc:creator>CLE</dc:creator>
      <dc:date>2018-07-16T21:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a variable after a Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478493#M123400</link>
      <description>&lt;P&gt;I'm not sure what you mean with the transpose?&lt;BR /&gt;PROC TRANSPOSE has both the ID and IDLABEL to allow you to dynamically name the fields, but it seems yours would translate directly. Did you try PROC TRANSPOSE and it didn't work somehow? If so, please post the code and an example of your input data and we can advise you on how it should be structured.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 21:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478493#M123400</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-16T21:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a variable after a Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478540#M123406</link>
      <description>&lt;P&gt;You could name your variables THIS_FY, THIS_FYTD, NEXT_FYTD and only assign labels&amp;nbsp;dynamically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 03:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478540#M123406</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-07-17T03:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a variable after a Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478566#M123417</link>
      <description>&lt;P&gt;My first thought was: avoid transposing, because it moves data into variable names and causes the problem. The table could be created by proc tabulate, but i have no idea how to set the background-colours.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 06:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478566#M123417</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-17T06:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a variable after a Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478725#M123472</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;My first thought was: avoid transposing, because it moves data into variable names and causes the problem. The table could be created by proc tabulate, but i have no idea how to set the background-colours.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can set the background color of a cell using a format to associate&amp;nbsp;either specific values or value ranges&amp;nbsp;with color values and then use a style statement to associate the format with the style element.&lt;/P&gt;
&lt;P&gt;Not pretty, just a syntax example:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value weightcolor
low- 85= 'green'
other  = 'red'
;
run;

proc tabulate data=sashelp.class;
   class sex age;
   var weight;
   tables sex*age,
          weight*(min*{style=[background=weightcolor.]}
                  max*{style=[background=weightcolor.]}
                  mean*{style=[background=weightcolor.]}
                 )
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 17:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Naming-a-variable-after-a-Proc-Transpose/m-p/478725#M123472</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-17T17:02:12Z</dc:date>
    </item>
  </channel>
</rss>

