<?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 Weekly Data Read in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555386#M154561</link>
    <description>&lt;P&gt;I have two years' worth of daily data. I want to break it up into weekly data Monday to Sunday.&amp;nbsp; I was going to write 104 if/then/else statements like the following, but I decided to ask if there is a better way.&amp;nbsp; I am using enterprise guide 7.1 and sas 9.4.&amp;nbsp; I am just comparing various metrics from week to week.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'30dec2018'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'13jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2019 15:56:37 GMT</pubDate>
    <dc:creator>pangea17</dc:creator>
    <dc:date>2019-05-01T15:56:37Z</dc:date>
    <item>
      <title>Weekly Data Read</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555386#M154561</link>
      <description>&lt;P&gt;I have two years' worth of daily data. I want to break it up into weekly data Monday to Sunday.&amp;nbsp; I was going to write 104 if/then/else statements like the following, but I decided to ask if there is a better way.&amp;nbsp; I am using enterprise guide 7.1 and sas 9.4.&amp;nbsp; I am just comparing various metrics from week to week.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'30dec2018'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'13jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 15:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555386#M154561</guid>
      <dc:creator>pangea17</dc:creator>
      <dc:date>2019-05-01T15:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Weekly Data Read</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555388#M154562</link>
      <description>&lt;P&gt;Definitely do not write 104 if-then statements &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it important that seg is 1,2,3 and so on? If not, check out the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604217.htm" target="_self"&gt;WeekU. Format&lt;/A&gt; that will bin the variable for you&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 16:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555388#M154562</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-01T16:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Weekly Data Read</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555389#M154563</link>
      <description>&lt;P&gt;Use the WEEK() function? There are several variations that can be customzied for what you need. &lt;BR /&gt;&lt;BR /&gt;Depending on how you're summarizing, you may be able to apply a format instead of creating a new variable as well.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1ka2ulrvrjlasn0z7beco2yrgas.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1ka2ulrvrjlasn0z7beco2yrgas.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an example of using a formatted date in a summary table. Although dates are not annual, the summary is annual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.stocks N NMISS min max mean median STACKODS;
class date;
format date year4.;
var open high low;
output out=want n= mean= sum= median= mean= / autoname autolabel;
ods output summary = want2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15692"&gt;@pangea17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two years' worth of daily data. I want to break it up into weekly data Monday to Sunday.&amp;nbsp; I was going to write 104 if/then/else statements like the following, but I decided to ask if there is a better way.&amp;nbsp; I am using enterprise guide 7.1 and sas 9.4.&amp;nbsp; I am just comparing various metrics from week to week.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;'30dec2018'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;'13jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 16:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555389#M154563</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-01T16:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Weekly Data Read</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555399#M154564</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15692"&gt;@pangea17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two years' worth of daily data. I want to break it up into weekly data Monday to Sunday.&amp;nbsp; I was going to write 104 if/then/else statements like the following, but I decided to ask if there is a better way.&amp;nbsp; I am using enterprise guide 7.1 and sas 9.4.&amp;nbsp; I am just comparing various metrics from week to week.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'30dec2018'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'06jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'13jan2019'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seg = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unless you have some shop requirement I would modify anything that requires name literals like: &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Pres Received Date'n&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might help to provide a small sample of your data and what the desired result would be, and if the result is a report (people read) or a data set needed by another process.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format is very likely the way to go. I don't like the default behaviors of the SAS week formats:&lt;/P&gt;
&lt;PRE&gt;data example;
  do d='25DEC2018'd to '18FEB2020'd;
   output;
  end;
run;
proc format library=work;
/* %0W and %0U use different defintions for 
   start of week and when to count a complete
   week the %0V
*/
picture myweek  (default=8)
low-high = '%Y-%0V'   (datatype=date)
;
run;

proc freq data=example;
   format d  myweek.;
run;&lt;/PRE&gt;
&lt;P&gt;Use V, U or W , check the documentation on either the Picture statement in Proc Format or the WEEK function with the U, V and W descriptor.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 16:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weekly-Data-Read/m-p/555399#M154564</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-01T16:32:07Z</dc:date>
    </item>
  </channel>
</rss>

