<?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: converting months to quarters in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676652#M23729</link>
    <description>&lt;P&gt;Transpose your input dataset to a usable dataset structure, and everything else is a piece of cake:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input;
input Obs Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec;
datalines;
1 2009 192284420 86376721 28526103 260386468 109975326 102833104 196728648 236996122 112413744 125401565 82391029 136042505 
2 2010 108645734 147656369 202158055 41160707 300627381 450987920 208694865 83456868 286846554 275721406 34982991 103938392 
3 2011 85730444 74328989 40098985 312654811 318149340 187270927 123394421 34273985 151565752 141528519 178043261 181668256
;

proc transpose data=input out=long;
by obs year;
var jan--dec;
run;

data have;
set long;
period = input(cats(_name_,year),monyy7.);
quarter = intnx('quarter',period,0,'b');
format period yymmd7. quarter yyq7. col1 dollar20.;
drop _name_ year;
rename col1=amount;
run;

proc summary data=have nway;
class obs quarter;
var amount;
output out=want (drop=_freq_ _type_) sum(amount)=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 14 Aug 2020 07:27:00 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-08-14T07:27:00Z</dc:date>
    <item>
      <title>converting months to quarters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676641#M23725</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have data like this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Obs Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 
1 2009 192284420 86376721 28526103 260386468 109975326 102833104 196728648 236996122 112413744 125401565 82391029 136042505 
2 2010 108645734 147656369 202158055 41160707 300627381 450987920 208694865 83456868 286846554 275721406 34982991 103938392 
3 2011 85730444 74328989 40098985 312654811 318149340 187270927 123394421 34273985 151565752 141528519 178043261 181668256 &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i want into convert into like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Obs Year Quarter1 Quarter2 Quarter3 Quarter4
1 2009 $307187244 $473194898 $546138514 $343835099
2 2010 $458460158 $792776008 $578998287 $414642789
3 2011 $200158418 $818075078 $309234158 $501240036&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can i do this? Thanks .&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 06:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676641#M23725</guid>
      <dc:creator>Raj00007</dc:creator>
      <dc:date>2020-08-14T06:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to quarters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676645#M23727</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
     array mx Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ;
	 array qt Quarter1 Quarter2 Quarter3 Quarter4 ;
	 do i=1 to 12 by 3;
	    j= int((i-1)/3 +1);
		qt(j) = sum(of mx(i), mx(i+1),mx(i+2));
	 end;&lt;BR /&gt;     keep year Quart:;&lt;BR /&gt;     format Quarter1-Quarter4 dollar12.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 06:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676645#M23727</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-14T06:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to quarters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676646#M23728</link>
      <description>&lt;P&gt;Can you fix the form in which you get the data? The first table you have posted looks like a report, not like a dataset. If you can't fix it, try something like (untested code):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  Quarter1 = sum(Jan, Feb, Mar);
  Quarter2 = ...;
  drop Jan--Dec;
  format Quarter: dollar.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 06:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676646#M23728</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-14T06:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to quarters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676652#M23729</link>
      <description>&lt;P&gt;Transpose your input dataset to a usable dataset structure, and everything else is a piece of cake:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input;
input Obs Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec;
datalines;
1 2009 192284420 86376721 28526103 260386468 109975326 102833104 196728648 236996122 112413744 125401565 82391029 136042505 
2 2010 108645734 147656369 202158055 41160707 300627381 450987920 208694865 83456868 286846554 275721406 34982991 103938392 
3 2011 85730444 74328989 40098985 312654811 318149340 187270927 123394421 34273985 151565752 141528519 178043261 181668256
;

proc transpose data=input out=long;
by obs year;
var jan--dec;
run;

data have;
set long;
period = input(cats(_name_,year),monyy7.);
quarter = intnx('quarter',period,0,'b');
format period yymmd7. quarter yyq7. col1 dollar20.;
drop _name_ year;
rename col1=amount;
run;

proc summary data=have nway;
class obs quarter;
var amount;
output out=want (drop=_freq_ _type_) sum(amount)=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 07:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-months-to-quarters/m-p/676652#M23729</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-14T07:27:00Z</dc:date>
    </item>
  </channel>
</rss>

