<?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: Extract data from the dataset for next 5 days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473839#M121640</link>
    <description>&lt;P&gt;There are probably simpler solutions if you only need to do this once, but I run into this same issue all the time (except in the opposite direction... I usually need today and the last n days), so I wrote a small macro to reference repeatedly. The only catch: the daylag parameter uses positive numbers to reference previous days (e.g. daylag=1 corresponds to yesterday's date), so if you want to reference future days, the number will be negative (e.g. daylag=-1 will be tomorrow's date).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date date9. var1;
datalines;
27JUN2018 53.5
28JUN2018 58.7
29JUN2018 41.8
30JUN2018 21.6
01JUL2018 17.6
02JUL2018 18.8
03JUL2018 17.7
04JUL2018 19.9
05JUL2018 27.7
06JUL2018 25.5
07JUL2018 26.9
;
run;

%macro day(daylag=0,format=DATE9.);
%local daystring;
%let daystring=%sysfunc(putn(%sysfunc(intnx(day,"%sysfunc(today(),DATE9.)"d,-(&amp;amp;daylag))),&amp;amp;format.));
&amp;amp;daystring
%mend;


data work.want;
set work.have;
where "%day(daylag=0)"d&amp;lt;=date&amp;lt;="%day(daylag=-4)"d;
format date DATE9.;
run;

proc print data=work.want; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jun 2018 17:35:28 GMT</pubDate>
    <dc:creator>ChanceTGardener</dc:creator>
    <dc:date>2018-06-27T17:35:28Z</dc:date>
    <item>
      <title>Extract data from the dataset for next 5 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473056#M121343</link>
      <description>&lt;P&gt;i have a dataset with one month data. i want to have another dataset with only next 5 days of data. dataset have variables ID, summary, poc, start date,support..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the next 5 days of start date dataset. - Thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table Task.test as&lt;BR /&gt;select * from task.deploy_file as A where Scheduled_Start_Date &amp;lt;= (Scheduled_Start_Date +5);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 15:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473056#M121343</guid>
      <dc:creator>radha009</dc:creator>
      <dc:date>2018-06-25T15:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from the dataset for next 5 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473486#M121515</link>
      <description>&lt;P&gt;What do you want exactly?&lt;/P&gt;
&lt;P&gt;Your&amp;nbsp;test&amp;nbsp;is always true:&amp;nbsp; A&amp;nbsp; &amp;lt;= A+5&amp;nbsp; is of course true&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 17:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473486#M121515</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-06-26T17:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from the dataset for next 5 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473761#M121610</link>
      <description>&lt;P&gt;yes, it is giving all records . I have a table with other variables and date field from today date until next one month (06-27-2018 to 07-27-2018). I am tyring to create a dataset&amp;nbsp; with only records from today date to next 5 days (06-27-2018 to 07-01-2018).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 14:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473761#M121610</guid>
      <dc:creator>radha009</dc:creator>
      <dc:date>2018-06-27T14:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from the dataset for next 5 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473836#M121638</link>
      <description>&lt;P&gt;So you want all tasks scheduled up to 5 days after the current date (i.e. the date the program is running).&amp;nbsp; If so, you can use the TODAY() function,&amp;nbsp; Using our proc sql code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table Task.test as
  select * from task.deploy_file as A where Scheduled_Start_Date &amp;lt;= (today() +5);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if the source table has historical tasks, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Task.test as
select * from task.deploy_file as A where Scheduled_Start_Date  between today() and (today()+5;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jun 2018 17:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473836#M121638</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-06-27T17:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data from the dataset for next 5 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473839#M121640</link>
      <description>&lt;P&gt;There are probably simpler solutions if you only need to do this once, but I run into this same issue all the time (except in the opposite direction... I usually need today and the last n days), so I wrote a small macro to reference repeatedly. The only catch: the daylag parameter uses positive numbers to reference previous days (e.g. daylag=1 corresponds to yesterday's date), so if you want to reference future days, the number will be negative (e.g. daylag=-1 will be tomorrow's date).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date date9. var1;
datalines;
27JUN2018 53.5
28JUN2018 58.7
29JUN2018 41.8
30JUN2018 21.6
01JUL2018 17.6
02JUL2018 18.8
03JUL2018 17.7
04JUL2018 19.9
05JUL2018 27.7
06JUL2018 25.5
07JUL2018 26.9
;
run;

%macro day(daylag=0,format=DATE9.);
%local daystring;
%let daystring=%sysfunc(putn(%sysfunc(intnx(day,"%sysfunc(today(),DATE9.)"d,-(&amp;amp;daylag))),&amp;amp;format.));
&amp;amp;daystring
%mend;


data work.want;
set work.have;
where "%day(daylag=0)"d&amp;lt;=date&amp;lt;="%day(daylag=-4)"d;
format date DATE9.;
run;

proc print data=work.want; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 17:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-data-from-the-dataset-for-next-5-days/m-p/473839#M121640</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2018-06-27T17:35:28Z</dc:date>
    </item>
  </channel>
</rss>

