<?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 weekly intervals with different start dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549401#M8670</link>
    <description>&lt;P&gt;I provided code that ought to work.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Apr 2019 19:34:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-04-08T19:34:46Z</dc:date>
    <item>
      <title>Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549382#M8657</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calculate a percentage of health care providers that log into an online platform within a week of their patients logging in. I have a dataset with the date that the patient logged in as well as the dates in which the providers have logged in. This dataset will end up being very large (as the study will go on for 2 years with over 150 participants), so I need to figure out how to automate a SAS code to calculate weekly intervals based off of the date that the patients logged in. Not all patients log in on the same day, so I can't figure out how to do this. I found this macro online which makes weekly intervals, but I would need these intervals to be based off of a variable (participant_startdate) instead of a date that I could put in like this '24Jan2019'. I hope that makes sense!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let start='24Jan2019'd;&lt;BR /&gt;%let end=date();&lt;/P&gt;&lt;P&gt;data set_weeks;&lt;BR /&gt;retain fmtname 'weeks';&lt;BR /&gt;start=&amp;amp;start;&lt;BR /&gt;end=start+6;&lt;BR /&gt;label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);&lt;BR /&gt;OUTPUT;&lt;BR /&gt;DO UNTIL (end &amp;gt; &amp;amp;end);&lt;BR /&gt;start=start+7;&lt;BR /&gt;end=end+7;&lt;BR /&gt;label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);&lt;BR /&gt;OUTPUT;&lt;BR /&gt;end;&lt;BR /&gt;keep fmtname start end label;&lt;BR /&gt;format start end mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549382#M8657</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T18:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549383#M8658</link>
      <description>&lt;P&gt;Instead of setting a macro variable with a date at the start of your program, you use a SAS data set (using the SET command) and then do the exact same calculations using the date the patient logged in that is in the data set.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549383#M8658</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T18:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549384#M8659</link>
      <description>&lt;P&gt;So I replaced %let start='24Jan2019',d; with %let start=participant_startdate; and put data set_weeks; set all_ids; (this is the dataset)&lt;/P&gt;&lt;P&gt;and it keeps crashing SAS. I get an error "OUT OF RESOURCES. Select: R. Retry, N. Tell procedure/DATA step no more resources, C. Cancel submitted statements, T. Terminate SAS"?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549384#M8659</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T18:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549385#M8660</link>
      <description>&lt;P&gt;First, as I envision the solution, there are no macro variables at all.&amp;nbsp;Everything is computed inside the DATA step, based on whatever the variable name is that contains the date when the patient logged on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are getting an out of resources message, we need to know how many records are in this data set ALL_IDS, and how many variables as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549385#M8660</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T18:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549386#M8661</link>
      <description>&lt;P&gt;As of right now, there are 107 observations and 11 variables from all_ids, but that number will grow as more are enrolled in the study. I would love to not use a macro if possible, but I have not figure out how to calculate a weekly interval variable. I would use the participant_startdate variable and have to count out 7 days from that date in order to get the weekly interval that I need for each participant. I have matched participants with their assigned providers so I can compare the provider login date with the patient login date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549386#M8661</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T19:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549388#M8662</link>
      <description>&lt;P&gt;Use participant_startdate instead of &amp;amp;start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You shouldn't have resource problems with a data set of that size.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549388#M8662</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T19:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549389#M8663</link>
      <description>&lt;P&gt;Is there an alternative way of calculating this? I keep getting the same error message.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549389#M8663</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T19:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549393#M8665</link>
      <description>&lt;P&gt;I think you have to figure out this Resources issue, rather than try to re-program the code. This code, as far as I can see, should not be the problem. But, just in case, please show us the actual code you are using.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549393#M8665</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T19:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549396#M8667</link>
      <description>&lt;P&gt;This is the code I am using that I keep getting the error for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let end=date();&lt;/P&gt;&lt;P&gt;data weeks;&lt;BR /&gt;set all_ids;&lt;BR /&gt;retain fmtname 'weeks';&lt;BR /&gt;start=participant_startdate;&lt;BR /&gt;end=start+6;&lt;BR /&gt;label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);&lt;BR /&gt;OUTPUT;&lt;BR /&gt;DO UNTIL (end &amp;gt; &amp;amp;end);&lt;BR /&gt;start=start+7;&lt;BR /&gt;end=end+7;&lt;BR /&gt;label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);&lt;BR /&gt;OUTPUT;&lt;BR /&gt;end;&lt;BR /&gt;keep fmtname start end label;&lt;BR /&gt;format start end mmddyy10.;&lt;BR /&gt;run;&lt;BR /&gt;end;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549396#M8667</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T19:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549399#M8668</link>
      <description>&lt;P&gt;So, as I said, you don't need (and should not have) any macro variables at all.&lt;/P&gt;
&lt;P&gt;&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 weeks;
set all_ids;
retain fmtname 'weeks';
start=participant_startdate;
end=start+6;
label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);
OUTPUT;
DO UNTIL (end &amp;gt; date());
start=start+7;
end=end+7;
label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);
OUTPUT;
end;
keep fmtname start end label;
format start end mmddyy10.;
run;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549399#M8668</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T19:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549400#M8669</link>
      <description>&lt;P&gt;Ok that makes sense... but how would you suggest I edit the code then? I am a little confused as to how to resolve this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549400#M8669</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T19:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549401#M8670</link>
      <description>&lt;P&gt;I provided code that ought to work.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549401#M8670</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T19:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549402#M8671</link>
      <description>&lt;P&gt;Sorry, didn't realize that was different. I am still getting the out of resources error message. I have no idea why.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549402#M8671</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-08T19:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549405#M8672</link>
      <description>&lt;P&gt;The only thing I can think of is that the data is not how you described it. Can you show us a portion of the data you are working with?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 19:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549405#M8672</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T19:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549407#M8673</link>
      <description>&lt;P&gt;is this what you are looking for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
	xd = today();
	end=input(put(xd,yymmdd8.),yymmdd8.);
	start='24JAN2019'd;
	call symput('end',put(end,yymmdd10.)); 
	call symput('start',put(start,yymmdd10.));
	put end;
	format start mmddyy10. end mmddyy10. ;
run;
data _null_;
	%put _user_;
run;
data set_weeks;
retain fmtname 'weeks';
start=&amp;amp;start;
end=start+6;
label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);
OUTPUT;
DO UNTIL (end &amp;gt; &amp;amp;end);
start=start+7;
end=end+7;
label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);
OUTPUT;
end;
keep fmtname start end label;
format start end mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Apr 2019 20:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549407#M8673</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-04-08T20:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549558#M8696</link>
      <description>&lt;P&gt;I don't think I can share the data but this is the full error I am getting from the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;601 data weeks;&lt;BR /&gt;602 set all_ids;&lt;BR /&gt;603 retain fmtname 'weeks';&lt;BR /&gt;604 start=participant_startdate;&lt;BR /&gt;605 end=start+6;&lt;BR /&gt;606 label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);&lt;BR /&gt;607 OUTPUT;&lt;BR /&gt;608 DO UNTIL (end &amp;gt; date());&lt;BR /&gt;609 start=start+7;&lt;BR /&gt;610 end=end+7;&lt;BR /&gt;611 label="Week: "||PUT(start, mmddyy10.)||" - "||PUT(end, mmddyy10.);&lt;BR /&gt;612 OUTPUT;&lt;BR /&gt;613 end;&lt;BR /&gt;614 keep fmtname start end label;&lt;BR /&gt;615 format start end mmddyy10.;&lt;BR /&gt;616 run;&lt;/P&gt;&lt;P&gt;ERROR: Insufficient space in file WORK.WEEKS.DATA.&lt;BR /&gt;ERROR: File WORK.WEEKS.DATA is damaged. I/O processing did not complete.&lt;BR /&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;1 at 605:10 129728360 at 609:12 129728360 at 610:8&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 2 observations read from the data set WORK.ALL_IDS.&lt;BR /&gt;WARNING: The data set WORK.WEEKS may be incomplete. When this step was stopped there were&lt;BR /&gt;129728363 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 50.60 seconds&lt;BR /&gt;cpu time 34.04 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;617 end;&lt;BR /&gt;---&lt;BR /&gt;180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 12:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549558#M8696</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-09T12:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create weekly intervals with different start dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549634#M8706</link>
      <description>&lt;P&gt;No, because not all start dates are going to be 24Jan2019. I need the start date to be the date that the participant logged in (participant_startdate).&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 15:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-weekly-intervals-with-different-start-dates/m-p/549634#M8706</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-04-09T15:02:08Z</dc:date>
    </item>
  </channel>
</rss>

