<?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: Report showing Months and Weeks in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45982#M12183</link>
    <description>You will need to use a combination of PROC TRANSPOSE, after separating current period observation into a separate file, perform the transpose, and then merge the two files back together. I suspect you can use PROC PRINT for generating the horizontal observations having 'week period' and 'month period' variable values, as generated by PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
Review the PROC TRANSPOSE documentation with reference to the BY and ID statements and the PREFIX= parameter. Also, for PROC PRINT, you will want to explore using the VAR statement and employ the use of a "stem variable prefix" ending in a colon character allowing you to abbreviate your variable list.&lt;BR /&gt;
&lt;BR /&gt;
The other option is to use a DATA step for full-control with PUT and column-position report generation.&lt;BR /&gt;
&lt;BR /&gt;
Search the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website for SAS-hosted documentation and supplemental technical and conference topic papers.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Wed, 17 Jun 2009 21:24:32 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-06-17T21:24:32Z</dc:date>
    <item>
      <title>Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45980#M12181</link>
      <description>Hi All,&lt;BR /&gt;
I want to produce an ods report that groups data by month as an across variable but if it is the current month, then group by weeks instead.  Is this possible and if so, what is the best proc to use? &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance</description>
      <pubDate>Wed, 17 Jun 2009 14:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45980#M12181</guid>
      <dc:creator>CameronLawson</dc:creator>
      <dc:date>2009-06-17T14:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45981#M12182</link>
      <description>proc FORMAT.&lt;BR /&gt;
Follow that with any statistical summary as most group by formatted value.&lt;BR /&gt;
FORMAT lets you invoke different formats based on the range of values in your variable, like "before this month" can define a date range.</description>
      <pubDate>Wed, 17 Jun 2009 17:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45981#M12182</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-06-17T17:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45982#M12183</link>
      <description>You will need to use a combination of PROC TRANSPOSE, after separating current period observation into a separate file, perform the transpose, and then merge the two files back together. I suspect you can use PROC PRINT for generating the horizontal observations having 'week period' and 'month period' variable values, as generated by PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
Review the PROC TRANSPOSE documentation with reference to the BY and ID statements and the PREFIX= parameter. Also, for PROC PRINT, you will want to explore using the VAR statement and employ the use of a "stem variable prefix" ending in a colon character allowing you to abbreviate your variable list.&lt;BR /&gt;
&lt;BR /&gt;
The other option is to use a DATA step for full-control with PUT and column-position report generation.&lt;BR /&gt;
&lt;BR /&gt;
Search the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website for SAS-hosted documentation and supplemental technical and conference topic papers.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 17 Jun 2009 21:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45982#M12183</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-17T21:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45983#M12184</link>
      <description>So I would need to set up a picture format that looked formatted any date not in the current month as something like monyy7. and anything in the current month as a week number?&lt;BR /&gt;
&lt;BR /&gt;
The beauty of forums....I would not have thought of doing it in such a gloriously simple way as that!&lt;BR /&gt;
&lt;BR /&gt;
It would be something like...(I'll be testing this at work)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let dtLow       = %sysfunc(datetime()-(8*86400));&lt;BR /&gt;
%let dtHigh      = %sysfunc(datetime()-(7*86400));&lt;BR /&gt;
proc format;&lt;BR /&gt;
picture yrWk&lt;BR /&gt;
 0 - &amp;amp;dtLow = '&lt;MY date="" format="" of="" month="" year=""&gt;'&lt;BR /&gt;
&amp;amp;dtHigh - high = '&lt;MY date="" format="" as="" date=""&gt;'&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks!  Time to dust off the old course notes to remember how to construct picture formats again....&lt;/MY&gt;&lt;/MY&gt;</description>
      <pubDate>Wed, 17 Jun 2009 21:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45983#M12184</guid>
      <dc:creator>CameronLawson</dc:creator>
      <dc:date>2009-06-17T21:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45984#M12185</link>
      <description>Honestly, I don't see how you are going to use a PICTURE format to satisfy programming for a tailored columnar report with week-start and month-start (or end) date column headings having some statistics values in the detail report rows.  The input data needs to be manipulated to derive a week-start date (using INTNX) for current period observations and a separate, additional SAS file for the "historical" date values beyond the current month period.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 17 Jun 2009 21:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45984#M12185</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-17T21:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45985#M12186</link>
      <description>The documentation is not very clear. The syntax you want might look like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format ;&lt;BR /&gt;
  picture yrWk&lt;BR /&gt;
         0 - &amp;amp;dtLow = 'W%w' (datatype=datetime)&lt;BR /&gt;
   &amp;amp;dtHigh - high   = '%b%Y'(datatype=datetime);&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Also, the default formatted length above is 4, so either increase this or use yrWk8.</description>
      <pubDate>Wed, 17 Jun 2009 23:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45985#M12186</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-06-17T23:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45986#M12187</link>
      <description>Sir, you impress as always.&lt;BR /&gt;
Thanks again.</description>
      <pubDate>Thu, 18 Jun 2009 02:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45986#M12187</guid>
      <dc:creator>CameronLawson</dc:creator>
      <dc:date>2009-06-18T02:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45987#M12188</link>
      <description>No pictures needed unless SAS doesn't already have suitable formats for week and month. The label for the formating a range, can be another format name.</description>
      <pubDate>Thu, 18 Jun 2009 11:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45987#M12188</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-06-18T11:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45988#M12189</link>
      <description>Thanks Peter, I think I recall this is supposed to be the case, but was not able to found it in the documentation.&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format ;&lt;BR /&gt;
  value x 0=time.&lt;BR /&gt;
          1=date.;&lt;BR /&gt;
data t;&lt;BR /&gt;
  x=0; put x= x.;&lt;BR /&gt;
  x=1; put x= x.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
doesn't work. How would you write this? My time to learn! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 18 Jun 2009 22:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45988#M12189</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-06-18T22:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45989#M12190</link>
      <description>You can use a format within a  format?  Really?&lt;BR /&gt;
&lt;BR /&gt;
Chris,&lt;BR /&gt;
I ended up using your suggestion&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
    x = 19;&lt;BR /&gt;
    x1 = 18;&lt;BR /&gt;
&lt;BR /&gt;
    dtLow = date()- x;&lt;BR /&gt;
    dtHigh = date()-x1;&lt;BR /&gt;
&lt;BR /&gt;
    call symputx('dtLow',dtLow);&lt;BR /&gt;
    call symputx('dtHigh',dtHigh);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;dtLow;&lt;BR /&gt;
%put &amp;amp;dtHigh;&lt;BR /&gt;
&lt;BR /&gt;
/*-- Create a new format that will parse dates as month yr if they are less than the High Value --*/&lt;BR /&gt;
proc format;&lt;BR /&gt;
  picture yrWk&lt;BR /&gt;
         0 - &amp;amp;dtLow = '%b%Y' (datatype=date)&lt;BR /&gt;
         &amp;amp;dtHigh - high   = '%m-%d'(datatype=date);&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 19 Jun 2009 02:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45989#M12190</guid>
      <dc:creator>CameronLawson</dc:creator>
      <dc:date>2009-06-19T02:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45990#M12191</link>
      <description>really, simple&lt;BR /&gt;
To embed (or "nest") a format place it within [ ] as the "label" [pre]%let tooEarly = 1jan2000 ;&lt;BR /&gt;
%let lastMonth= %sysfunc( intnx( month,"&amp;amp;sysdate9"d, -1, e ), date9 );&lt;BR /&gt;
%let latest   = %sysfunc( intnx( year, "&amp;amp;sysdate9"d,  0, e ), date9 );&lt;BR /&gt;
  proc format ;&lt;BR /&gt;
      value mulDt( default=11 )&lt;BR /&gt;
               low     - "&amp;amp;earliest"d  = 'err:Too old'&lt;BR /&gt;
         "&amp;amp;earliest"d  - "&amp;amp;lastMonth"d = [yyMon.] &lt;BR /&gt;
         "&amp;amp;lastMonth"d - "&amp;amp;latest"d    = [week.]&lt;BR /&gt;
         "&amp;amp;latest"d    -  high         = 'futures' &lt;BR /&gt;
      ;&lt;BR /&gt;
  run ;[/pre] then use format MULDT. on a format statement for the class date variable.</description>
      <pubDate>Fri, 19 Jun 2009 13:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45990#M12191</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-06-19T13:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45991#M12192</link>
      <description>Square brackets! I don't recall ever seeing this before, thank you Peter. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Glad it helped, Cameron. You also have Peter's syntax to consider now.</description>
      <pubDate>Sun, 21 Jun 2009 23:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45991#M12192</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-06-21T23:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Report showing Months and Weeks</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45992#M12193</link>
      <description>wow you learn something new everyday!  Thanks Peter and Chris</description>
      <pubDate>Sun, 21 Jun 2009 23:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Report-showing-Months-and-Weeks/m-p/45992#M12193</guid>
      <dc:creator>CameronLawson</dc:creator>
      <dc:date>2009-06-21T23:34:56Z</dc:date>
    </item>
  </channel>
</rss>

