<?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: Accounting for missing dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61581#M13385</link>
    <description>If i get what you want this example may help you:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/*for example: this is your data*/&lt;BR /&gt;
data test;&lt;BR /&gt;
LENGTH date $10.;&lt;BR /&gt;
input Number_of_Sightings date $;&lt;BR /&gt;
date_new=input(date,ddmmyy10.);&lt;BR /&gt;
week=week(date_new); /*return the number of week according to this year*/&lt;BR /&gt;
format date_new ddmmyy10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
10 01112008&lt;BR /&gt;
12 05112008&lt;BR /&gt;
1  06112008&lt;BR /&gt;
3  09112008&lt;BR /&gt;
4  14112008&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/*count sightings per week*/&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select count(Number_of_Sightings) as Sightings &lt;BR /&gt;
      ,week&lt;BR /&gt;
from test&lt;BR /&gt;
group by week;&lt;BR /&gt;
quit;</description>
    <pubDate>Sun, 16 Nov 2008 14:43:07 GMT</pubDate>
    <dc:creator>yonib</dc:creator>
    <dc:date>2008-11-16T14:43:07Z</dc:date>
    <item>
      <title>Accounting for missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61579#M13383</link>
      <description>Let's pretend I have a file on UFO sightings with two items: Date and Number_of_Sightings. I must make a report on the number of UFO sightings per week, with the week running Saturday to Friday. I can not simply output a running total when weekday(Date) eq 6 because my input file includes only the dates when there was at least one UFO sighting. No spaceships - no record for that day. Is there some (hopefully elegant) way of handling this?</description>
      <pubDate>Sun, 16 Nov 2008 11:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61579#M13383</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-16T11:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Accounting for missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61580#M13384</link>
      <description>Hi:&lt;BR /&gt;
  With several procedures -- most notably for producing reports, Proc Report and Proc Tabulate -- there is a way to "preload" a user-defined format that gives info on the WHOLE universe of  situations for which you want to have a report.&lt;BR /&gt;
&lt;BR /&gt;
  It wasn't exactly clear to me what you wanted, but if you wanted to see a day listed, even if it had zero UFO sightings, with a total at the bottom of the whole week, then perhaps this previous forum posting has some code that would be useful:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=9017⌹" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=9017⌹&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  You'll also want to pay attention to the ORDER= option so you can get the days of the week sorted in the right order. Perhaps you'll find that there are more UFO sightings on "party nights"!&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 16 Nov 2008 12:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61580#M13384</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-11-16T12:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Accounting for missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61581#M13385</link>
      <description>If i get what you want this example may help you:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/*for example: this is your data*/&lt;BR /&gt;
data test;&lt;BR /&gt;
LENGTH date $10.;&lt;BR /&gt;
input Number_of_Sightings date $;&lt;BR /&gt;
date_new=input(date,ddmmyy10.);&lt;BR /&gt;
week=week(date_new); /*return the number of week according to this year*/&lt;BR /&gt;
format date_new ddmmyy10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
10 01112008&lt;BR /&gt;
12 05112008&lt;BR /&gt;
1  06112008&lt;BR /&gt;
3  09112008&lt;BR /&gt;
4  14112008&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/*count sightings per week*/&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select count(Number_of_Sightings) as Sightings &lt;BR /&gt;
      ,week&lt;BR /&gt;
from test&lt;BR /&gt;
group by week;&lt;BR /&gt;
quit;</description>
      <pubDate>Sun, 16 Nov 2008 14:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61581#M13385</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2008-11-16T14:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Accounting for missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61582#M13386</link>
      <description>You can setup a "all possible week-ending dates" file as a placelholder, using a DATA step, such as:&lt;BR /&gt;
&lt;BR /&gt;
DATA WKDATES;&lt;BR /&gt;
FORMAT WKENDDT DATE9.;&lt;BR /&gt;
DO WKENDDT=INTNX('WEEK',TODAY(),-5,'E') TO INTNX('WEEK',TODAY(),-0,'E') BY 7;&lt;BR /&gt;
  OUTPUT;&lt;BR /&gt;
END;&lt;BR /&gt;
STOP;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Then create a week-summary file of your sightings data, join the two files, and generate your desired report.  Use the INTNX function to assign a week-ending date to use with grouping your detail data up to a week-summary level.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 17 Nov 2008 01:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Accounting-for-missing-dates/m-p/61582#M13386</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-11-17T01:30:28Z</dc:date>
    </item>
  </channel>
</rss>

