<?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: Ordering Months Starting with September in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441650#M110512</link>
    <description>&lt;P&gt;FYI - leaving PROC TRANSPOSE as is would be dangerous because you're renaming the columns manually but its possible if the data is in a different order in a different run the years would be mixed up. So using the ID statement to automatically label the years is a better approach.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Mar 2018 17:25:38 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-02T17:25:38Z</dc:date>
    <item>
      <title>Ordering Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441640#M110506</link>
      <description>&lt;P&gt;I am currently trying to order the months in my dataset&amp;nbsp; Sep-May and have been unable to find a solution that works. I have sorted the data by month to transpose it into the format I needed but this ordered it alphabetically. I have submitted my code below and included the resulting table.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=perm.snow1a out=perm.snowy2;&lt;BR /&gt;by month;&lt;BR /&gt;where Year &amp;gt;=1992 and Year&amp;lt;=2001;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc Transpose data=perm.snowy2 name= Month out=perm.snowyy2 (rename=(col1=Year1992 col2=Year1993 col3=Year1994&lt;BR /&gt;col4=Year1995 col5=Year1996 col6=Year1997 col7=Year1998 col8=Year1999 col9=Year2000 col10=Year2001));&lt;BR /&gt;var Snowfall;&lt;BR /&gt;by Month;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=perm.snowyy2 noobs;&lt;BR /&gt;title "Monthly Snowfall by Year";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3b2.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18929i12C435829B2B79EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="3b2.JPG" alt="3b2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441640#M110506</guid>
      <dc:creator>emkotnik</dc:creator>
      <dc:date>2018-03-02T17:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441644#M110509</link>
      <description>&lt;P&gt;Is month a SAS date? If so, add a new variable such as below and sort by that variable instead. You don't need to display it in the report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_order =month( intnx('month', date, 4, 'b'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441644#M110509</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-02T17:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441646#M110510</link>
      <description>&lt;P&gt;No, Month wasn't a SAS date, it was a character variable in the original dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441646#M110510</guid>
      <dc:creator>emkotnik</dc:creator>
      <dc:date>2018-03-02T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441647#M110511</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc Transpose data=perm.snowy2 name= Month out=perm.snowyy2 prefix=Year;
var Snowfall;
by Month;
ID Year;
idlabel year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change your proc transpose though....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And convert the month to a SAS date then, use any year.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;set perm2.snowyy2;
date_var = input( catt('01', substr(month, 1,3), '2018'), date9.);
date_order =month( intnx('month', date, 4, 'b'));

run;

proc sort data=have;
by date_order ;
run;

proc print data=have;
var Month Year: ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441647#M110511</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-02T17:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441650#M110512</link>
      <description>&lt;P&gt;FYI - leaving PROC TRANSPOSE as is would be dangerous because you're renaming the columns manually but its possible if the data is in a different order in a different run the years would be mixed up. So using the ID statement to automatically label the years is a better approach.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441650#M110512</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-02T17:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441656#M110513</link>
      <description>&lt;P&gt;Thank you so much! Everything looks great! I am just learning SAS so I either forget about or am unaware of a lot of the options available for each procedure. The help with renaming the columns was a nice added bonus! Thank you again, I really appreciate it.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441656#M110513</guid>
      <dc:creator>emkotnik</dc:creator>
      <dc:date>2018-03-02T17:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441657#M110514</link>
      <description>&lt;P&gt;An easy way:&amp;nbsp; create a new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;set have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;length newmonth $ 8;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;select (month);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Sep') newmonth='01 = Sep';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Oct') newmonth='02 = Oct';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Nov') newmonth='03 = Nov';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Dec') newmonth='04 = Dec';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Jan') newmonth='05 = Jan';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Feb') newmonth='06 = Feb';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Mar') newmonth='07 = Mar';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Apr') newmonth='08 = Apr';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('May') newmonth='09 = May';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Jun') newmonth='10 = Jun';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Jul') newmonth='11 = Jul';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;when ('Aug') newmonth='12 = Aug';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;otherwise;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you have a variable (NEWMONTH) that can be used for sorting, and you can choose which variable (MONTH or NEWMONTH) should be used for reporting.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 17:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441657#M110514</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-02T17:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441931#M110543</link>
      <description>&lt;P&gt;Since your goal is to produce a report, I think a better solution is to make a calendar date, and use it to generate a variable (call it SNOWYEAR) to use as a classification variable in proc tabulate or proc report.&amp;nbsp; No need for sorting, whether alphabetically or chronologically:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need;
   date=input(cats('01',month,year),date9.);
   snowyear=year(intnx('year.6',date,0,'E'));
run;

proc tabulate data=need noseps ;
  where not (month in ('JUN','JUL','AUG'));
  class snowyear date;
  format date monname3. ;
  var snow;
  tables  
     date= ' ' 
   , snowyear="Monthly Snow by Snow Season"*sum=' '*snow=' '*f=6.0  
     / rts=6;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The CATS function will concatenate both numeric and character values, generating strings like "01OCT1996", which is then converted into a sas date value via the INPUT function.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Snowyear is then generated by
&lt;OL&gt;
&lt;LI&gt;Using INTNX to get the last date in the time-span known as "YEAR.6"&amp;nbsp; (years beginning in June, and ending in May.&lt;BR /&gt;&lt;BR /&gt;So INTNX('YEAR.6','01OCT1994'D,0,'E') says to add zero YEAR.6 spans to 01oct1994 and get the&amp;nbsp;endding date in that span (that's the 'E' in the function) - resulting in 31may1995&lt;/LI&gt;
&lt;LI&gt;Then use the YEAR function to get snowyear = 1995&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;proc tabulate then just organizes the table per your desired layout.&amp;nbsp; I should add that the rows in proc tabulate are in ascending chronological order, even thought the "format date monname3." shows the 3-letter month abbreviations.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 02 Mar 2018 21:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441931#M110543</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-02T21:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months Starting with September</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441993#M110560</link>
      <description>&lt;P&gt;Thank you very much! I had tried this as a simple solution but was wondering if there was a more elegant solution. I'm still learning SAS and can find a solution but know that its likely not the most efficient or elegant way.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 01:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441993#M110560</guid>
      <dc:creator>emkotnik</dc:creator>
      <dc:date>2018-03-03T01:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441995#M110561</link>
      <description>&lt;P&gt;Thank you! I really appreciate that you took the time to explain the functions and steps you took, I'm still learning SAS and the explanations really help clarify everything. I did have one quick question though. What is the purpose of the *f=6.0 option in the table statement?&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 02:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441995#M110561</guid>
      <dc:creator>emkotnik</dc:creator>
      <dc:date>2018-03-03T02:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441996#M110562</link>
      <description>&lt;P&gt;The "f=6.0" is the way to tell proc tabulate what format to use for the cell values (and the width of the column).&amp;nbsp;&amp;nbsp; The&amp;nbsp; default format would have presented 2 decimal point values.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 02:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441996#M110562</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-03T02:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441997#M110563</link>
      <description>&lt;P&gt;Great, that makes sense. I recognized the 6.0 as a format but the *f was unfamiliar to me. Thank you very much, I appreciate it!&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 02:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ordering-Months/m-p/441997#M110563</guid>
      <dc:creator>emkotnik</dc:creator>
      <dc:date>2018-03-03T02:12:33Z</dc:date>
    </item>
  </channel>
</rss>

