<?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 Ordering dates pursuant to proc transpose function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855811#M338185</link>
    <description>&lt;P&gt;I have a dataset that has counts of activity types grouped by month and year (for a 13 month period).&amp;nbsp; This dataset will be compiled monthly (at the beginning of each month for the preceding 13 months), so the immediately preceding month (December, in January's instance) will have two (2) appearances.&amp;nbsp; One for the month immediately preceding (December 2022) and one for 13 months ago (December 2021).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've also been tasked with re-creating the last seven (7) months' data (June 2022 through December 2022).&amp;nbsp; Everything is working outside the proc transpose not ordering dates (months/years - or however this needs to be formatted) chronologically from left to right.&amp;nbsp; More specifically, March 2022 continually appears as the last month listed (to the right) with every other month/year appearing in order as wanted.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data volumes;
set volumes_1;
format month_2 monyy.;
month_2 = input(month !! "01",yymmdd8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;^This code creates a new variable, month_2, in a date format.&amp;nbsp; Full disclosure, I've run the proc transpose (included below) using a date formatted month_2 and a character formatted month variable with the same results (March 2022 not cooperating and appearing in order).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=volumes (drop=month);
by transaction_type_code month_2;
run;


proc transpose data=volumes out=PIVOT (drop=_:);
by transaction_type_code;
id month_2;
var volume;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;^There's the sort and subsequent proc transpose, to result in:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hnb_matt_d_0-1674758057721.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79851iD76312AA9276F8BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hnb_matt_d_0-1674758057721.png" alt="hnb_matt_d_0-1674758057721.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've utilized multiple date formats for month_2, with none of them working properly.&amp;nbsp; HELP!&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jan 2023 18:36:53 GMT</pubDate>
    <dc:creator>hnb_matt_d</dc:creator>
    <dc:date>2023-01-26T18:36:53Z</dc:date>
    <item>
      <title>Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855811#M338185</link>
      <description>&lt;P&gt;I have a dataset that has counts of activity types grouped by month and year (for a 13 month period).&amp;nbsp; This dataset will be compiled monthly (at the beginning of each month for the preceding 13 months), so the immediately preceding month (December, in January's instance) will have two (2) appearances.&amp;nbsp; One for the month immediately preceding (December 2022) and one for 13 months ago (December 2021).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've also been tasked with re-creating the last seven (7) months' data (June 2022 through December 2022).&amp;nbsp; Everything is working outside the proc transpose not ordering dates (months/years - or however this needs to be formatted) chronologically from left to right.&amp;nbsp; More specifically, March 2022 continually appears as the last month listed (to the right) with every other month/year appearing in order as wanted.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data volumes;
set volumes_1;
format month_2 monyy.;
month_2 = input(month !! "01",yymmdd8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;^This code creates a new variable, month_2, in a date format.&amp;nbsp; Full disclosure, I've run the proc transpose (included below) using a date formatted month_2 and a character formatted month variable with the same results (March 2022 not cooperating and appearing in order).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=volumes (drop=month);
by transaction_type_code month_2;
run;


proc transpose data=volumes out=PIVOT (drop=_:);
by transaction_type_code;
id month_2;
var volume;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;^There's the sort and subsequent proc transpose, to result in:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hnb_matt_d_0-1674758057721.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79851iD76312AA9276F8BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hnb_matt_d_0-1674758057721.png" alt="hnb_matt_d_0-1674758057721.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've utilized multiple date formats for month_2, with none of them working properly.&amp;nbsp; HELP!&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 18:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855811#M338185</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2023-01-26T18:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855814#M338186</link>
      <description>&lt;P&gt;Create a dummy level of&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;transaction_type_code=.&lt;/LI-CODE&gt;
&lt;P&gt;with missing value and one record for each MONTH in the correct order.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855814#M338186</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2023-01-26T19:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855815#M338187</link>
      <description>&lt;P&gt;If you don't have all of the months in every level of the by variable, such as your transaction_type_code variable then that is likely. The order of appearance of the ID values sets which order the variable appears.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I generally don't worry about the order of variables in a data set as anytime people need to read things you specify the order in the report generating code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can quite often complicate a task by placing actual date into variable names like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without actual data or an example of what you need for the output it is a tad difficult to suggest another approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855815#M338187</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-26T19:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855823#M338188</link>
      <description>&lt;P&gt;If the goal is to create a report or an Excel output with calendar names as the column headings, then PROC TRANSPOSE simply is not the way to go. There is nothing in PROC TRANSPOSE that will force the result into calendar order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead you want to use PROC REPORT with an ACROSS variable and the option ORDER=INTERNAL. If you do this, then this problem you are having goes away, and furthermore doesn't involve you creating a transposed data set. &lt;A href="https://communities.sas.com/t5/New-SAS-User/COLUMN-NAME-Variable-IS-A-MACRO-USING-THAT-IN-PROC-REPORT/m-p/854979#M37681" target="_self"&gt;EXAMPLE&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855823#M338188</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-26T19:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855828#M338190</link>
      <description>&lt;P&gt;Since you didn't provide sample data, I took the liberty of creating some to play with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Make fake data*/
data volumes;
	call streaminit(12345);
	do transaction_type_code = "CHECK","CASH","CARD";
		DO YEAR=2021 TO 2022;
			do Month=1 TO 12;
				month_2 = input(CATS(YEAR,PUT(month,Z2.),"01"),yymmdd8.);
				Volume=rand('INTEGER',10,1000);
				IF month_2 &amp;gt;= '01DEC2021'd then output;
			end;
		end;
	end;
format month_2 monyy.; DROP YEAR;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This produced an input data set that looked like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASJedi_2-1674760877309.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79855iF5FA4ED481D27793/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASJedi_2-1674760877309.png" alt="SASJedi_2-1674760877309.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then I ran your code against that data. The only mod I did was to drop YEAR, which you didn't have in your original data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=volumes (drop=month year);
	by transaction_type_code month_2;
run;

proc transpose data=volumes out=PIVOT (drop=_:);
   by transaction_type_code;
   id month_2; 
   var volume;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is the result from SAS 9.4 M7, Windowing environment (PC SAS):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASJedi_3-1674761071977.png" style="width: 895px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79856iFD459088F23C2401/image-dimensions/895x47?v=v2" width="895" height="47" role="button" title="SASJedi_3-1674761071977.png" alt="SASJedi_3-1674761071977.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;From Enterprise Guide 8.3 running on SAS 9.4M7 (I run in dark mode)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASJedi_4-1674761164678.png" style="width: 892px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79857i5377DC6DA1D84CB0/image-dimensions/892x87?v=v2" width="892" height="87" role="button" title="SASJedi_4-1674761164678.png" alt="SASJedi_4-1674761164678.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And from Viya 2023. (also in dark mode):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASJedi_6-1674761343520.png" style="width: 885px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79859i63775E7717000B31/image-dimensions/885x73?v=v2" width="885" height="73" role="button" title="SASJedi_6-1674761343520.png" alt="SASJedi_6-1674761343520.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I can't seem to replicate your results using your code. Is it possible to share a few rows of the original &lt;STRONG&gt;volumes&lt;/STRONG&gt; data set without violating privacy?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855828#M338190</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-01-26T19:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855831#M338191</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hnb_matt_d_0-1674762449769.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79861i40B800622EC23E5A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hnb_matt_d_0-1674762449769.png" alt="hnb_matt_d_0-1674762449769.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Working with this version...&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855831#M338191</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2023-01-26T19:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855832#M338192</link>
      <description>&lt;P&gt;Can't really share the specific transaction_type _code.&amp;nbsp; I can tell you there are ~400 of them with ~2.5 billion occurrences across those 400 in the last 13 months.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this will be an automated code execution and output, so I'd rather not hard-code dates/years.&amp;nbsp; Need this to be as self-sustainingly dynamic as possible.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855832#M338192</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2023-01-26T19:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855833#M338193</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306354"&gt;@hnb_matt_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Need this to be as self-sustainingly dynamic as possible.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC REPORT! I have already provided a small example.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855833#M338193</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-26T20:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855834#M338194</link>
      <description>&lt;P&gt;Reviewing this now.&amp;nbsp; I may take overnight to digest,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;.&amp;nbsp; It's been an interesting Thursday thus far.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855834#M338194</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2023-01-26T20:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855835#M338195</link>
      <description>&lt;P&gt;This really looks like the same thing that proc tabulate was doing (which seemed to work correctly), but I need the Output Data formatted and not just the Results tab to be correct.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855835#M338195</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2023-01-26T20:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855838#M338196</link>
      <description>&lt;P&gt;The proc report example provided also doesn't work with the date formatting needed.&amp;nbsp; These transaction code volumes are being aggregated by month.&amp;nbsp; Having a date of 1/1/2022 appearing to represent January 2022 won't work.&amp;nbsp; The inconsistency in the presentation will be noticed and called out.&amp;nbsp; This, unfortunately, is a compliance-based document and has to adhere to established guidelines.&amp;nbsp; Not my call on that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855838#M338196</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2023-01-26T20:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855839#M338197</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;but I need the Output Data formatted and not just the Results tab to be correct.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand what this means, but there are a gazillion and 12 different formatting options in PROC REPORT.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855839#M338197</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-26T20:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855840#M338198</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306354"&gt;@hnb_matt_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;These transaction code volumes are being aggregated by month.&amp;nbsp; Having a date of 1/1/2022 appearing to represent January 2022 won't work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;All you have to do is change the format.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855840#M338198</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-26T20:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855841#M338199</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306354"&gt;@hnb_matt_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can't really share the specific transaction_type _code.&amp;nbsp; I can tell you there are ~400 of them with ~2.5 billion occurrences across those 400 in the last 13 months.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this will be an automated code execution and output, so I'd rather not hard-code dates/years.&amp;nbsp; Need this to be as self-sustainingly dynamic as possible.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Have you verified that each transaction code has a record in each month?&lt;/P&gt;
&lt;P&gt;I suspect you may be leaving out some details. If you have duplicate month values for any given transaction code using the shown code would fail with an error similar to this:&lt;/P&gt;
&lt;PRE&gt;ERROR: The ID value "DEC22" occurs twice in the same BY group.
&lt;/PRE&gt;
&lt;P&gt;Which means that the maximum number of records you could be dealing with is 400 codes * 13 months and expect the transpose to work which is WAY short of 2.5 billion.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855841#M338199</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-26T20:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering dates pursuant to proc transpose function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855844#M338201</link>
      <description>&lt;P&gt;Building on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;solution a brute force method, that's not ideal is to select the columns in the date order from a list of macro variables. There's a few ways of doing this but it's data driven. Basically adds two more steps to your code. See the last two steps in the code below. Note because it's data driven, if you change from 7 to 12 months, you could either just select a smaller amount by modifying the SQL query or if the data changes to just 7 months it would be data driven so you have some options to make it dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Make fake data*/
data volumes;
	call streaminit(12345);
	do transaction_type_code = "CHECK","CASH","CARD";
		DO YEAR=2021 TO 2022;
			do Month=1 TO 12;
				month_2 = input(CATS(YEAR,PUT(month,Z2.),"01"),yymmdd8.);
				Volume=rand('INTEGER',10,1000);
				IF month_2 &amp;gt;= '01DEC2021'd then output;
			end;
		end;
	end;
format month_2 monyy.; 
run;

proc sort data=volumes (drop=month year);
	by transaction_type_code month_2;
run;

proc transpose data=volumes out=PIVOT (drop=_:);
   by transaction_type_code;
   id month_2; 
   var volume;
run;

proc sql noprint;
select distinct month_2 into :date_list separated by " ," from volumes
order by month_2;
quit;

proc sql;
create table volumes_report as 
select transaction_type_code, &amp;amp;date_list
from pivot;
quit;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-dates-pursuant-to-proc-transpose-function/m-p/855844#M338201</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-26T20:59:25Z</dc:date>
    </item>
  </channel>
</rss>

