<?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: Formatting transposed Date headers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736560#M229475</link>
    <description>&lt;P&gt;First, date values need to be handled as such, not as strings that can't be used in calculations and do not sort correctly.&lt;/P&gt;
&lt;P&gt;Second, always strive for a long dataset layout, as this can most easily be used in procedures without prior knowledge of the actual content.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length
  catgy $25
  month_ 4
  Sales 8
  Return 8
;
input catgy month_ :monyy5. sales return;
format month_ yymmd7.;
datalines;
Engineering JAN20 10 20 
Engineering JAN20 22 46 
Engineering FEB20 30 17  
Engineering FEB20 60 32   
Engineering MAR20 40 44 
Engineering APR20 60 44   
Engineering APR20 40 22
;

proc transpose
  data=have
  out=long (rename=(_name_=cat col1=value));
;
by catgy month_;
var sales return;
run;

proc report data=long;
column catgy cat value,month_;
define catgy / "Department" group;
define cat / "Category" group;
define value / "" analysis;
define month_ / "" across;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Apr 2021 09:06:56 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-04-23T09:06:56Z</dc:date>
    <item>
      <title>Formatting transposed Date headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736541#M229459</link>
      <description>&lt;P&gt;I received a data file similar to this code that needs to be transposed to show dates as headers&lt;/P&gt;
&lt;PRE&gt;data have;
 length catgy $25
	month_ $5 
	Sales 8
	Return 8;
	input catgy -- return;
datalines;
Engineering JAN20 10 20 
Engineering JAN20 22 46 
Engineering FEB20 30 17  
Engineering FEB20 60 32   
Engineering MAR20 40 44 
Engineering APR20 60 44   
Engineering APR20 40 22
;
run;

proc transpose data=have out =have2 let;
id month_;
var sales return;
by catgy;
run;&lt;/PRE&gt;
&lt;P&gt;Output from the proc transpose is this&lt;/P&gt;
&lt;PRE&gt;catgy	_NAME_	JAN20	FEB20	MAR20	APR20
Engineering	Sales	22	60	40	40
Engineering	Return	46	32	44	22
&lt;/PRE&gt;
&lt;P&gt;The issue&amp;nbsp; is I cannot format the date headers (which will be dynamic each month).&amp;nbsp; As an example I want to format the headers with a number with 2 decimal points (ie 22 becomes 22.00)&amp;nbsp; Is there a way I can handle this without hardcoding the date headers?&amp;nbsp; Month_ originally is a single column that was transposed to horizontal format.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 04:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736541#M229459</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-04-23T04:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting transposed Date headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736545#M229463</link>
      <description>&lt;P&gt;Why do want to transpose the dataset?&amp;nbsp; Is it for a report?&amp;nbsp; If so use PROC REPORT.&lt;/P&gt;
&lt;P&gt;If not how are you planning to use this new structure that couldn't be done more easily with the original structure?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 04:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736545#M229463</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-23T04:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting transposed Date headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736547#M229465</link>
      <description>&lt;P&gt;The decimal point is not allowed in variable names. You could add a label and use that during reporting.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 05:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736547#M229465</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-23T05:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting transposed Date headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736560#M229475</link>
      <description>&lt;P&gt;First, date values need to be handled as such, not as strings that can't be used in calculations and do not sort correctly.&lt;/P&gt;
&lt;P&gt;Second, always strive for a long dataset layout, as this can most easily be used in procedures without prior knowledge of the actual content.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length
  catgy $25
  month_ 4
  Sales 8
  Return 8
;
input catgy month_ :monyy5. sales return;
format month_ yymmd7.;
datalines;
Engineering JAN20 10 20 
Engineering JAN20 22 46 
Engineering FEB20 30 17  
Engineering FEB20 60 32   
Engineering MAR20 40 44 
Engineering APR20 60 44   
Engineering APR20 40 22
;

proc transpose
  data=have
  out=long (rename=(_name_=cat col1=value));
;
by catgy month_;
var sales return;
run;

proc report data=long;
column catgy cat value,month_;
define catgy / "Department" group;
define cat / "Category" group;
define value / "" analysis;
define month_ / "" across;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 09:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736560#M229475</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-23T09:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting transposed Date headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736586#M229495</link>
      <description>Thanks for the response. For your routine in proc report  "define month_ / "" across is there a way to show returns as a percentage of sales?  In this case the proc report would show sales as a numeric and returns as a percentage8.3&lt;BR /&gt;&lt;BR /&gt;Also in your response were you saying that its best to use a long version of date yymmd7 as opposed to the monyy5</description>
      <pubDate>Fri, 23 Apr 2021 13:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736586#M229495</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-04-23T13:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting transposed Date headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736599#M229505</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;Also in your response were you saying that its best to use a long version of date yymmd7 as opposed to the monyy5&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"Long" meant the data set structure: one record per date instead of "wide" with multiple dates(hidden in variable names to an extent) per record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to share your formula for " returns as a percentage of sales". But Proc report does allow you to do calculations based on results of the statistics calculated.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 15:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-transposed-Date-headers/m-p/736599#M229505</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-23T15:04:23Z</dc:date>
    </item>
  </channel>
</rss>

