<?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 tabulating dates in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7745#M183</link>
    <description>hey all, &lt;BR /&gt;
&lt;BR /&gt;
i have a dataset name risks_data - that contains fromdate, todate and risks. fromdate and todate in the format of date9. and risks number. as below. &lt;BR /&gt;
&lt;BR /&gt;
fromdate                  todate                   risks&lt;BR /&gt;
02MAR2009             02MAR2010          1&lt;BR /&gt;
21FEB2010             21FEB2011            1&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
and i am need to find the number of risks in three different months - 1st Jan 2010, 1st Feb 2010, 1st March 2010 so I had the below macro codes. &lt;BR /&gt;
&lt;BR /&gt;
%macro date;&lt;BR /&gt;
Data date_&amp;amp;month;&lt;BR /&gt;
set risks_data  ( keep = fromdate todate risks);&lt;BR /&gt;
Where fromdate &amp;lt;= "%sysfunc(putn(%sysfunc(intnx(Month,%sysfunc(date()),-1)),EURDFDE9.))"D &amp;lt;= todate and risks;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend date;&lt;BR /&gt;
&lt;BR /&gt;
once thats done, I need to tabulate the number of risks into a table showing something as below (this is where I am not sure how to go about doing it) &lt;BR /&gt;
&lt;BR /&gt;
Effective_Day          Risks&lt;BR /&gt;
01Jan2010              2311&lt;BR /&gt;
01Feb2010             1452&lt;BR /&gt;
01March2010          2785&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
hope someone can help me out on this one!! &lt;BR /&gt;
&lt;BR /&gt;
thanks in advance!&lt;BR /&gt;
Yennie</description>
    <pubDate>Thu, 22 Apr 2010 03:07:04 GMT</pubDate>
    <dc:creator>Yennie</dc:creator>
    <dc:date>2010-04-22T03:07:04Z</dc:date>
    <item>
      <title>tabulating dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7745#M183</link>
      <description>hey all, &lt;BR /&gt;
&lt;BR /&gt;
i have a dataset name risks_data - that contains fromdate, todate and risks. fromdate and todate in the format of date9. and risks number. as below. &lt;BR /&gt;
&lt;BR /&gt;
fromdate                  todate                   risks&lt;BR /&gt;
02MAR2009             02MAR2010          1&lt;BR /&gt;
21FEB2010             21FEB2011            1&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
and i am need to find the number of risks in three different months - 1st Jan 2010, 1st Feb 2010, 1st March 2010 so I had the below macro codes. &lt;BR /&gt;
&lt;BR /&gt;
%macro date;&lt;BR /&gt;
Data date_&amp;amp;month;&lt;BR /&gt;
set risks_data  ( keep = fromdate todate risks);&lt;BR /&gt;
Where fromdate &amp;lt;= "%sysfunc(putn(%sysfunc(intnx(Month,%sysfunc(date()),-1)),EURDFDE9.))"D &amp;lt;= todate and risks;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend date;&lt;BR /&gt;
&lt;BR /&gt;
once thats done, I need to tabulate the number of risks into a table showing something as below (this is where I am not sure how to go about doing it) &lt;BR /&gt;
&lt;BR /&gt;
Effective_Day          Risks&lt;BR /&gt;
01Jan2010              2311&lt;BR /&gt;
01Feb2010             1452&lt;BR /&gt;
01March2010          2785&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
hope someone can help me out on this one!! &lt;BR /&gt;
&lt;BR /&gt;
thanks in advance!&lt;BR /&gt;
Yennie</description>
      <pubDate>Thu, 22 Apr 2010 03:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7745#M183</guid>
      <dc:creator>Yennie</dc:creator>
      <dc:date>2010-04-22T03:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: tabulating dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7746#M184</link>
      <description>continue..... &lt;BR /&gt;
le "%sysfunc(putn(%sysfunc(intnx(Month,%sysfunc(date()),-1)),EURDFDE9.))"D le todate and risks;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend date;&lt;BR /&gt;
&lt;BR /&gt;
once thats done, I need to tabulate the number of risks into a table showing something as below (this is where I am not sure how to go about doing it) &lt;BR /&gt;
&lt;BR /&gt;
Effective_Day          Risks&lt;BR /&gt;
01Jan2010              2311&lt;BR /&gt;
01Feb2010             1452&lt;BR /&gt;
01March2010          2785&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
hope someone can help me out on this one!! &lt;BR /&gt;
&lt;BR /&gt;
thanks in advance!&lt;BR /&gt;
Yennie</description>
      <pubDate>Thu, 22 Apr 2010 03:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7746#M184</guid>
      <dc:creator>Yennie</dc:creator>
      <dc:date>2010-04-22T03:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: tabulating dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7747#M185</link>
      <description>Hi Yennie&lt;BR /&gt;
&lt;BR /&gt;
Some questions and ideas.&lt;BR /&gt;
&lt;BR /&gt;
Q: are the values for fromdate and todate really strings or are these SAS date values with a SAS date format assigned? You can easily check this by running a PROC CONTENTS.&lt;BR /&gt;
&lt;BR /&gt;
Q: Your example data shows the same dates for fromdate and todate. Is this how your data really looks like? And would that mean that these 2 cases wouldn't be counted anywhere?&lt;BR /&gt;
&lt;BR /&gt;
Q: What happens if a risk period (fromdate to todate) goes over a monthend. Should this risk be counted in 2 months? Or only when it started?&lt;BR /&gt;
&lt;BR /&gt;
Forget about using any macro code. It won't be needed.&lt;BR /&gt;
&lt;BR /&gt;
What most likely has to be done is creating some additional observations (i.e. one obs per month where the risk exists) and then a PROC TABULATE with an appropriate format applied to the variable containing the date.&lt;BR /&gt;
&lt;BR /&gt;
Have also a look at functions like INTCK() and INTNX().&lt;BR /&gt;
&lt;BR /&gt;
Please provide also some "real" sample data, best in form of a data step creating a SAS table.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick

Message was edited by: Patrick</description>
      <pubDate>Thu, 22 Apr 2010 09:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/tabulating-dates/m-p/7747#M185</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-04-22T09:36:09Z</dc:date>
    </item>
  </channel>
</rss>

