<?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: How to generate daily date series from start? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643678#M192145</link>
    <description>&lt;P&gt;If you have SAS/ETS license (check using PROC PRODUCT_STATUS) you can use the TIMESERIES procedure to fill the missing dates and impute the values if you're so inclined. You can set it to carry the last observation forward or assign it 0 or missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example where I fill in missing months (after I delete them in the first step for testing).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*1*/
data ibm;
	set sashelp.stocks;
	where stock='IBM';

	if month(date)=7 then
		delete;
run;

proc sort data=ibm;
	by date;
run;

/*2*/
proc timeseries data=ibm out=ibm_no_missing;
	id date interval=month start='01Aug1986'd end='01Dec2005'd;
	var open;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Apr 2020 16:59:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-04-28T16:59:33Z</dc:date>
    <item>
      <title>How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643654#M192134</link>
      <description>&lt;P&gt;I have a "start date" and I want to creates a series of daily dates from that date for each individual person in my code.&lt;/P&gt;
&lt;P&gt;How do I do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 15:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643654#M192134</guid>
      <dc:creator>mariamon0</dc:creator>
      <dc:date>2020-04-28T15:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643656#M192135</link>
      <description>&lt;P&gt;Maybe by using a loop in a data step, if your date is a sas-date. Posting example data of what you have and showing what you expect as result will help us to help you.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 15:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643656#M192135</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-28T15:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643660#M192136</link>
      <description>&lt;P&gt;please try the below code untested code , I am assuming that the start_date is numeric date&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 i = start_date to today();
output;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Apr 2020 15:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643660#M192136</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-28T15:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643678#M192145</link>
      <description>&lt;P&gt;If you have SAS/ETS license (check using PROC PRODUCT_STATUS) you can use the TIMESERIES procedure to fill the missing dates and impute the values if you're so inclined. You can set it to carry the last observation forward or assign it 0 or missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example where I fill in missing months (after I delete them in the first step for testing).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*1*/
data ibm;
	set sashelp.stocks;
	where stock='IBM';

	if month(date)=7 then
		delete;
run;

proc sort data=ibm;
	by date;
run;

/*2*/
proc timeseries data=ibm out=ibm_no_missing;
	id date interval=month start='01Aug1986'd end='01Dec2005'd;
	var open;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Apr 2020 16:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643678#M192145</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-28T16:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643690#M192148</link>
      <description>&lt;P&gt;Just change the start and end dates.&amp;nbsp; Just noticed&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s comment, edited to include a persons list, then merged the two files&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Specify start and end dates*/
%let start_date=%str(1JAN2020);
%let end_date=%str(1APR2020);
data daily;
	date_N="&amp;amp;start_date"d;
	do while (date_N&amp;lt;="&amp;amp;end_date"d);
		output;
		date_N=intnx('day', date_N, 1, 's');
	end;
	format date_N date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;data persons;&lt;BR /&gt;input name $;&lt;BR /&gt;cards;&lt;BR /&gt;John&lt;BR /&gt;Mary&lt;BR /&gt;Sally&lt;BR /&gt;Harry&lt;BR /&gt;;&lt;BR /&gt;proc sql;&lt;BR /&gt;  create table comb as &lt;BR /&gt;    select * from persons,daily&lt;BR /&gt;      order by name;&lt;BR /&gt; quit;&lt;BR /&gt; &lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 18:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643690#M192148</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-04-28T18:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643693#M192150</link>
      <description>None of the solutions so far factor in your individual person/date. One option is to generate the date list and a unique person list and cross join them as well. &lt;BR /&gt;&lt;BR /&gt;If you're using the TIMESERIES approach you could just add a BY statement to the code for each individual and it would fill it in.</description>
      <pubDate>Tue, 28 Apr 2020 18:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643693#M192150</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-28T18:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643898#M192225</link>
      <description>&lt;P&gt;I am definitely confused. Is there a way to do that with the intnx function? How would I do it with time series.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data web.finalgoal;&lt;/P&gt;
&lt;P&gt;set web.goaldata;&lt;/P&gt;
&lt;P&gt;randomization_date=start_date;&lt;/P&gt;
&lt;P&gt;I dont have a variable for end_date do I need to create one?&lt;/P&gt;
&lt;P&gt;by study_id;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 12:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643898#M192225</guid>
      <dc:creator>mariamon0</dc:creator>
      <dc:date>2020-04-29T12:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate daily date series from start?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643930#M192246</link>
      <description>&lt;P&gt;I have broken this down into steps for you.&amp;nbsp; Assuming&amp;nbsp;&lt;CODE class=" language-sas"&gt;randomization_date is&amp;nbsp;numerical&amp;nbsp;date&amp;nbsp;values.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Untested code for your time series&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select min(randomization_date),max(randomization_date) 
	into :startdate, :enddate
		from web.goaldata;
quit;
data daily;
	date_N="&amp;amp;start_date"d;
	do while (date_N&amp;lt;="&amp;amp;end_date"d);
		output;
		date_N=intnx('day', date_N, 1, 's');
	end;
	format date_N date9.;
run;
proc sql;
     create table studies as 
  select distinct study_id from  web.goaldata;
quit;
proc sql;
  create table web.finalgoal as 
    select * from studies,daily
      order by studies;
 quit;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Apr 2020 13:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-daily-date-series-from-start/m-p/643930#M192246</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-04-29T13:25:29Z</dc:date>
    </item>
  </channel>
</rss>

