<?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: Create date variable weekly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247838#M46482</link>
    <description>&lt;P&gt;If I understand what you want AND if your dates are SAS date values this might work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   do  class_days = schoold_start_day to school_end_day by 7;
      output;
   end;
   format classdays date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your dates aren't SAS date values (why not:)&amp;nbsp;) but are character then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   do  class_days = (input(school_start_day,date9.)) to (input(school_end_day,date9.)) by 7;
      output;
   end;
   format class_days date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Feb 2016 20:13:12 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-02-03T20:13:12Z</dc:date>
    <item>
      <title>Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247834#M46480</link>
      <description>&lt;P&gt;I have a tabel as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DAY &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SCHOOL_START_DAY &amp;nbsp; &amp;nbsp;SCHOOL_END_DAY &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;monday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01MAY2016&lt;/P&gt;
&lt;P&gt;tuesday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11JAN 2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01MAY2016&lt;/P&gt;
&lt;P&gt;WEDNESDAY &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01MAY2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .....ETC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It means for first row school starts on 11jan2016 and every monday there is a class thrue 01may2016. For the second row school starts on 11jan2016 and every tueday there is a class thrue 01may2016.&lt;/P&gt;
&lt;P&gt;i need a table shows each week like this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;day &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;school_start_day &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;school_end_day &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;class_days&lt;/P&gt;
&lt;P&gt;monday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11jan2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01may2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11jan2016&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11jan2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01may2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18jan2016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11jan2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01may2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25jan2016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11jan2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01may2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01feb2016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;.......etc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monday &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01MAY2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25apr2016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;TUeSDAY &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01MAY2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12jan2016&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;TUeSDAY &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01MAY2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19jan2016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;TUeSDAY &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01MAY2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26jan2016&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;TUeSDAY &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11JAN2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01MAY2016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2feb2016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...etc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;is that possible to create second table?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 19:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247834#M46480</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-02-03T19:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247836#M46481</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data school;
   input day:$upcase12. (start end)(:date9.);
   format start end date9.;
   shift = whichc(day,'SUNDAY','MONDAY','TUESDAY','WEDNESDAY');
   i = intck(cats('week.',shift),start,end);
   do c = 0 to i;
      classDay = intnx(cats('week.',shift),start,c,'B');
      output;
      end;
   format classDay weekdate.;
   cards;
monday     11JAN2016  01MAY2016
tuesday    11JAN2016  01MAY2016
WEDNESDAY  11JAN2016  01MAY2016 
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1745i7A20EF688E1FA000/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 20:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247836#M46481</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-03T20:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247838#M46482</link>
      <description>&lt;P&gt;If I understand what you want AND if your dates are SAS date values this might work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   do  class_days = schoold_start_day to school_end_day by 7;
      output;
   end;
   format classdays date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your dates aren't SAS date values (why not:)&amp;nbsp;) but are character then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   do  class_days = (input(school_start_day,date9.)) to (input(school_end_day,date9.)) by 7;
      output;
   end;
   format class_days date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Feb 2016 20:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247838#M46482</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-03T20:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247840#M46483</link>
      <description>&lt;P&gt;Thank you so much.&lt;/P&gt;
&lt;P&gt;Quick question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a big table for the first table i wrote:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cards;&lt;BR /&gt;monday 11JAN2016 01MAY2016&lt;BR /&gt;tuesday 11JAN2016 01MAY2016&lt;BR /&gt;WEDNESDAY 11JAN2016 01MAY2016&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can not write this one like that. I need to mention as table &amp;nbsp;and variable name.??&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 20:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247840#M46483</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-02-03T20:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247846#M46485</link>
      <description>&lt;P&gt;My program is an example you can adapt it to a program that uses a SET statement. &amp;nbsp;It is intended to show you the relevant funtions and loop logic needed to produce the output. &amp;nbsp;I would expect you to look at the documentation for each of the functions and any other statements you are not familiar with. &amp;nbsp;I am not a code writting service.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 20:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247846#M46485</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-03T20:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247850#M46487</link>
      <description>&lt;P&gt;For second part gave an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Invalid DO loop control information, either the INITIAL or TO expression &lt;BR /&gt; is missing or the BY expression is missing, zero, or invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 20:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247850#M46487</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-02-03T20:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247880#M46502</link>
      <description>&lt;P&gt;Which code generated the error? Post the exact code you ran as minor typos might generate that message.&amp;nbsp;And post some actually rows of data that generated the error.&lt;/P&gt;
&lt;P&gt;If you used&amp;nbsp;the character form of the code example I posted and your data is not the same format then the appropriate format should be used. If the format is variable then possibly ANYDTDTE of some length. If your data is SAS values, such as would have a format of DATE9 or MMDDYY10 or such when you run Proc Contents on the input set then use the non-character version. It may help to post the results of running Proc Contents on your existing data.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 23:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247880#M46502</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-03T23:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247967#M46530</link>
      <description>&lt;P&gt;If it is not in write line like that. This one doesn't work, why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data school;&lt;BR /&gt; input day:$upcase12. (start end)(:date9.);&lt;BR /&gt; format start end date9.;&lt;BR /&gt; shift = whichc(day,'SUNDAY','MONDAY','TUESDAY','THURSDAY','WEDNESDAY','FRIDAY');&lt;BR /&gt; i = intck(cats('week.',shift),start,end);&lt;BR /&gt; do c = 0 to i;&lt;BR /&gt; classDay = intnx(cats('week.',shift),start,c,'B');&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; format classDay weekdate.;&lt;BR /&gt; cards;&lt;BR /&gt;monday 11JAN2016 01MAY2016&lt;BR /&gt;tuesday 11JAN2016 01MAY2016&lt;BR /&gt;WEDNESDAY 11JAN2016 02MAY2016 &lt;BR /&gt;WEDNESDAY 11JAN2016 01MAY2016 &lt;BR /&gt;THURSDAY 15FEB2016 01MAY2016&lt;BR /&gt;monday 11JAN2016 02MAY2016&lt;/P&gt;
&lt;P&gt;;;;;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc print;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 13:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247967#M46530</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-02-04T13:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247990#M46540</link>
      <description>&lt;P&gt;data person;&lt;BR /&gt; input @1 day $8. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70859"&gt;@12&lt;/a&gt; start DATE9. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8008"&gt;@22&lt;/a&gt; end date9.;&lt;BR /&gt; format start DATE9. end date9.;&lt;/P&gt;
&lt;P&gt;datalines; &lt;BR /&gt;FRIDAY 11JAN2016 01MAY2016&lt;BR /&gt;MONDAY 11JAN2016 01MAY2016&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt; set PERSON;&lt;BR /&gt; do DAYS = START to END by 7;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; format DAYS date9.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I run this query it worked. But the days are not right. Says 11Jan2016 is FRIDAY. Please help&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 14:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/247990#M46540</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-02-04T14:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248011#M46553</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52929"&gt;@lerdem&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;If it is not in write line like that. This one doesn't work, why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data school;&lt;BR /&gt; input day:$upcase12. (start end)(:date9.);&lt;BR /&gt; format start end date9.;&lt;BR /&gt; shift = whichc(day,'SUNDAY','MONDAY','TUESDAY','THURSDAY','WEDNESDAY','FRIDAY');&lt;BR /&gt; i = intck(cats('week.',shift),start,end);&lt;BR /&gt; do c = 0 to i;&lt;BR /&gt; classDay = intnx(cats('week.',shift),start,c,'B');&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; format classDay weekdate.;&lt;BR /&gt; cards;&lt;BR /&gt;monday 11JAN2016 01MAY2016&lt;BR /&gt;tuesday 11JAN2016 01MAY2016&lt;BR /&gt;WEDNESDAY 11JAN2016 02MAY2016 &lt;BR /&gt;WEDNESDAY 11JAN2016 01MAY2016 &lt;BR /&gt;THURSDAY 15FEB2016 01MAY2016&lt;BR /&gt;monday 11JAN2016 02MAY2016&lt;/P&gt;
&lt;P&gt;;;;;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc print;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;You have the calculation of shift wrong Wednesday comes before Thursday, should be this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;shift = whichc(day,'SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise the program works. &amp;nbsp;I copied the code from from YOUR post and submitted it using SAS EG.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 15:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248011#M46553</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-04T15:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248019#M46556</link>
      <description>&lt;P&gt;OK, Last question&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data school;&lt;BR /&gt;input day:$upcase12. (start end)(:date9.);&lt;BR /&gt;format start end date9.;&lt;BR /&gt;shift = whichc(day,'SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY');&lt;BR /&gt;i = intck(cats('week.',shift),start,end);&lt;BR /&gt;do c = 0 to i;&lt;BR /&gt;classDay = intnx(cats('week.',shift),start,c,'B');&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;format classDay weekdate.;&lt;BR /&gt;cards;&lt;BR /&gt;FRIDAY 11JAN2016 01MAY2016&lt;BR /&gt;MONDAY 11JAN2016 01MAY2016&lt;BR /&gt;SATURDAY 11JAN2016 01MAY2016&lt;BR /&gt;THURSDAY 11JAN2016 02MAR2016&lt;BR /&gt;THURSDAY 11JAN2016 01MAY2016&lt;BR /&gt;THURSDAY 15FEB2016 01MAY2016&lt;BR /&gt;THURSDAY 03MAR2016 01MAY2016&lt;BR /&gt;TUESDAY 11JAN2016 02MAR2016&lt;BR /&gt;TUESDAY 11JAN2016 01MAY2016&lt;BR /&gt;TUESDAY 03MAR2016 01MAY2016&lt;BR /&gt;WEDNESDAY 11JAN2016 01MAY2016&lt;BR /&gt;;;;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i keep gettin this error:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Invalid DO loop control information, either the INITIAL or TO expression &lt;BR /&gt; is missing or the BY expression is missing, zero, or invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you so much,appreciate your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 15:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248019#M46556</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-02-04T15:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248025#M46558</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52929"&gt;@lerdem&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;OK, Last question&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data school;&lt;BR /&gt;input day:$upcase12. (start end)(:date9.);&lt;BR /&gt;format start end date9.;&lt;BR /&gt;shift = whichc(day,'SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY');&lt;BR /&gt;i = intck(cats('week.',shift),start,end);&lt;BR /&gt;do c = 0 to i;&lt;BR /&gt;classDay = intnx(cats('week.',shift),start,c,'B');&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;format classDay weekdate.;&lt;BR /&gt;cards;&lt;BR /&gt;FRIDAY 11JAN2016 01MAY2016&lt;BR /&gt;MONDAY 11JAN2016 01MAY2016&lt;BR /&gt;SATURDAY 11JAN2016 01MAY2016&lt;BR /&gt;THURSDAY 11JAN2016 02MAR2016&lt;BR /&gt;THURSDAY 11JAN2016 01MAY2016&lt;BR /&gt;THURSDAY 15FEB2016 01MAY2016&lt;BR /&gt;THURSDAY 03MAR2016 01MAY2016&lt;BR /&gt;TUESDAY 11JAN2016 02MAR2016&lt;BR /&gt;TUESDAY 11JAN2016 01MAY2016&lt;BR /&gt;TUESDAY 03MAR2016 01MAY2016&lt;BR /&gt;WEDNESDAY 11JAN2016 01MAY2016&lt;BR /&gt;;;;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i keep gettin this error:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Invalid DO loop control information, either the INITIAL or TO expression &lt;BR /&gt; is missing or the BY expression is missing, zero, or invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you so much,appreciate your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't get any error. &amp;nbsp;I suspect that "for you" for some reason the start and end dates are not being read correctly. &amp;nbsp;Modify the code so that the data generation part does not run. &amp;nbsp;Just after the input statement add&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;output; return;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and post the result of proc print of that data back here. &amp;nbsp;Also show the log the entire relevant part not just the any error message. &amp;nbsp;You are making this rather difficult with your cryptic description of the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 16:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248025#M46558</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-04T16:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create date variable weekly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248030#M46559</link>
      <description>&lt;P&gt;Sorry, I made a bad assumption that the start date was the first day of the class. So the loop needs to be adusted to start on the correct day. I think this works. However you will need to provide the full name of the day of the week to read the day of week with this provided custom format. The example also does address a start date other than monday.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue dayofweek (upcase)
'SUNDAY'   = 1
'MONDAY'   = 2
'TUESDAY'  = 3
'WEDNESDAY'= 4
'THURSDAY' = 5
'FRIDAY'   = 6
'SATURDAY' = 7
;
RUN;


data person;
   informat day DAYOFWEEK. start  DATE9.  end date9.;
   input  day start  end ;
   format start DATE9. end date9.;
   if WEEKDAY(START) &amp;lt; day then do;
      start= intnx('day',start,day-weekday(start));
   end;
   if WEEKDAY(START) &amp;gt; day then do;
      start= intnx('day',start,day-weekday(start)+7);
   end;
datalines; 
FRIDAY 11JAN2016 01MAY2016
MONDAY 11JAN2016 01MAY2016
SUNDAY 11JAN2016 01MAY2016
MONDAY 13JAN2016 01MAY2016
;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Feb 2016 16:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-date-variable-weekly/m-p/248030#M46559</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-04T16:28:57Z</dc:date>
    </item>
  </channel>
</rss>

