<?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: Creating date-based arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773759#M245852</link>
    <description>FYI - have worked with both research data and administrative data that's similar - kids in care or homeless shelters or health care drug analysis where prescription data needs to be mapped to adverse events. Very similar to your use cases and data was always long. The initial wide approach is very common with social scientists though &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
    <pubDate>Tue, 12 Oct 2021 20:52:41 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-10-12T20:52:41Z</dc:date>
    <item>
      <title>Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773728#M245836</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;So I have a dataset of clients with one or more social service episodes and within each episode there can be one or more events. Each event has a begin date and an end date. I want to make a wide dataset so that there is a column for each day for a given time period, for example, calendar year 2019. And for each event I want to flag the days that occur during the given time period. There is more that I want to do but this would be a great start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt;infile datalines;
input Client_ID $ Episode_ID $ Event_ID $ Begin_Date :date9. End_Date :date9. Event_Plcmnt $;
format Begin_date End_Date date9.;
datalines;
001	001	001	20MAY2019	23MAY2019	GC
001	001	002	22MAY2019	23MAY2019	OTHER
001	001	003	23MAY2019	23OCT2019	GC
001	001	004	29JUN2019	30JUN2019	OTHER
001	001	006	14JUL2019	15JUL2019	OTHER
001	001	007	19JUL2019	23JUL2019	OTHER
001	001	005	25JUL2019	08AUG2019	OTHER
001	001	008	09AUG2019	10AUG2019	OTHER
001	001	009	11AUG2019	12AUG2019	OTHER
001	002	010	01NOV2019	16APR2020	URC
&lt;/PRE&gt;
&lt;P&gt;And here is what I want it to look like:&lt;/P&gt;
&lt;TABLE border="1" width="102.02147137150466%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="10%" height="44px"&gt;Client_ID&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;Episode_ID&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;Event_ID&lt;/TD&gt;
&lt;TD width="2.5%" height="44px"&gt;Begin_Date&lt;/TD&gt;
&lt;TD width="1.25%" height="44px"&gt;End_Date&lt;/TD&gt;
&lt;TD width="0.625%" height="44px"&gt;Event_Plcmnt&lt;/TD&gt;
&lt;TD width="5%" height="44px"&gt;01JAN2019&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;02JAN2019&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;20MAY2019&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;21MAY2019&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;22MAY2019&lt;/TD&gt;
&lt;TD width="5%" height="44px"&gt;23MAY2019&lt;/TD&gt;
&lt;TD width="2.5%"&gt;24MAY2019&lt;/TD&gt;
&lt;TD width="1.25%"&gt;25MAY2019&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;30DEC2019&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;31DEC2019&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;
&lt;P&gt;001&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;20May2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;23May2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;GC&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="44px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;002&lt;/TD&gt;
&lt;TD width="2.5%" height="44px"&gt;22May2019&lt;/TD&gt;
&lt;TD width="1.25%" height="44px"&gt;23May2019&lt;/TD&gt;
&lt;TD width="0.625%" height="44px"&gt;
&lt;P&gt;Other&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="5%" height="44px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="44px"&gt;1&lt;/TD&gt;
&lt;TD width="5%" height="44px"&gt;1&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;003&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;23May2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;23Oct2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;GC&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="2.5%"&gt;1&lt;/TD&gt;
&lt;TD width="1.25%"&gt;1&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;004&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;29Jun2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;30Jun2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;Other&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;005&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;14Jul2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;15Jul2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;Other&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;006&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;19Jul2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;23Jul2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;Other&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;007&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;25Jul2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;8Aug2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;Other&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;008&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;09Aug2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;10Aug2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;Other&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;009&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;11Aug2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;12Aug2019&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;Other&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%" height="29px"&gt;001&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;002&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;010&lt;/TD&gt;
&lt;TD width="2.5%" height="29px"&gt;01Nov2019&lt;/TD&gt;
&lt;TD width="1.25%" height="29px"&gt;16Apr2020&lt;/TD&gt;
&lt;TD width="0.625%" height="29px"&gt;URC&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;...&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="10%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="1.25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="0.625%"&gt;...&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;1&lt;/TD&gt;
&lt;TD width="0.3125%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;I've truncated, of course, to save space.&amp;nbsp; Also, there are a number of other columns that I did not include in the sample dataset that I would need to carry over.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know what you all think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Marc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773728#M245836</guid>
      <dc:creator>ModeratelyWise</dc:creator>
      <dc:date>2021-10-12T19:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773729#M245837</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So I have a dataset of clients with one or more social service episodes and within each episode there can be one or more events. Each event has a begin date and an end date. I want to make a wide dataset ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Stop right there. You should not make this a wide dataset. There are almost no cases where you really need to do this, and it makes the rest of your programming much more difficult. Of course, to be 100% sure, we need to know what analysis or report you plan to do with this wide data set; most of the time, the same analysis or report can be obtain with much less work by NOT making a wide data set.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 19&lt;/A&gt;: Long beats wide.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773729#M245837</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-12T19:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773739#M245841</link>
      <description>&lt;P&gt;If all of your client ids were involved with the same date ranges there might be some limited sense in a "wide" format but one suspects that your actual data doesn't meet that requirement.&lt;/P&gt;
&lt;P&gt;Making a long set is easy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   do ddate = begin_date to End_date;
      output;
   end;
   format ddate date9.;
run;&lt;/PRE&gt;
&lt;P&gt;DDate has each date in the given intervals. it would be very easy to add a flag variable to the above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to use the above depends on what you are actually trying to accomplish. Having a data set with hundreds of "flag" variables is seldom easy to work with.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773739#M245841</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-12T19:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773746#M245844</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for the response.&amp;nbsp; Interesting, I was told to try arrays by someone at my work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the issue.&amp;nbsp; I am trying to calculate the number of occurrences of maltreatment that occur per 100,000 days in care for clients who are in one of five placement settings (the event_plcmnt column).&amp;nbsp; To do this I need to total the number of days that clients spend in one of these settings.&amp;nbsp; It would be nice if the data were clean and straight forward but it isn't.&amp;nbsp; The dates between events often overlap or have gaps and sometimes the dates for events are nested inside the dates for another event in the same episode. What I need to do is find a way to fix the gaps and overlaps and fix them and then join with table of maltreatment occurrence dates to see where the client was when the maltreatment occurred.&amp;nbsp; Finally I total the number of days for each placement setting&amp;nbsp; for all the clients and the number of maltreatments in each of the five setting and divide the latter by the former to get the rates.&amp;nbsp; Can I do this with the long format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773746#M245844</guid>
      <dc:creator>ModeratelyWise</dc:creator>
      <dc:date>2021-10-12T20:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773748#M245846</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks it works just like you said. Do you think I can attain the output I talk about in my above comment with a long data set?&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773748#M245846</guid>
      <dc:creator>ModeratelyWise</dc:creator>
      <dc:date>2021-10-12T20:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773755#M245849</link>
      <description>Yes, you can 100% do what you want with the long format. &lt;BR /&gt;If you search on here for overlaps with date intervals you'll find many examples of exactly how this can be done. &lt;BR /&gt;If you want it specific for your exact use case, perhaps ask that question specifically. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Duration-in-Business-days-and-overlapping-days/m-p/479987?search-action-id=69214952839&amp;amp;search-result-uid=479987" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Duration-in-Business-days-and-overlapping-days/m-p/479987?search-action-id=69214952839&amp;amp;search-result-uid=479987&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Finding-overlapping-durations/m-p/298268?search-action-id=69214952839&amp;amp;search-result-uid=298268" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Finding-overlapping-durations/m-p/298268?search-action-id=69214952839&amp;amp;search-result-uid=298268&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Collapsing-rows-by-overlapping-dates/m-p/622561?search-action-id=69214952839&amp;amp;search-result-uid=622561" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Collapsing-rows-by-overlapping-dates/m-p/622561?search-action-id=69214952839&amp;amp;search-result-uid=622561&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773755#M245849</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-12T20:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773758#M245851</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390502"&gt;@ModeratelyWise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks it works just like you said. Do you think I can attain the output I talk about in my above comment with a long data set?&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you add a "flag" numeric value you can make a report that reads like that very easily.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   do ddate = begin_date to End_date;
      flag=1;
      output;
   end;
   format ddate date9.;
run;

proc tabulate data=want;
  class  Client_ID  Episode_ID  Event_ID Event_Plcmnt  ddate;
  var flag;
  table Client_ID*Episode_ID*  Event_ID*Event_Plcmnt,
      ddate=' '*flag=' '*sum=' '*f=best5.
      /misstext=' ' 
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Though with the extreme number of dates likely to result I might suggest making that the row variable and the other variables the column variables (unless you have a lot of Client_id values in which case the result will be ugly pretty much whatever you do).&lt;/P&gt;
&lt;P&gt;The =' ' are suppressing variable names or statistic names from the report. The f=best5. is showing the "sum" without decimals which is the default for the procedure. The /misstext option sets what to show for missing values of the sum, in this case a simple blank, so you do not see mostly cells with a dot for value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More variables might make Proc Report more attractive with the DDATE as an across variable. Depends a lot on actual data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without some serious justification I won't even attempt to create a data set.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773758#M245851</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-12T20:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773759#M245852</link>
      <description>FYI - have worked with both research data and administrative data that's similar - kids in care or homeless shelters or health care drug analysis where prescription data needs to be mapped to adverse events. Very similar to your use cases and data was always long. The initial wide approach is very common with social scientists though &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773759#M245852</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-12T20:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773777#M245862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390502"&gt;@ModeratelyWise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for the response.&amp;nbsp; Interesting, I was told to try arrays by someone at my work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the issue.&amp;nbsp; I am trying to calculate the number of occurrences of maltreatment that occur per 100,000 days in care for clients who are in one of five placement settings (the event_plcmnt column).&amp;nbsp; To do this I need to total the number of days that clients spend in one of these settings.&amp;nbsp; It would be nice if the data were clean and straight forward but it isn't.&amp;nbsp; The dates between events often overlap or have gaps and sometimes the dates for events are nested inside the dates for another event in the same episode. What I need to do is find a way to fix the gaps and overlaps and fix them and then join with table of maltreatment occurrence dates to see where the client was when the maltreatment occurred.&amp;nbsp; Finally I total the number of days for each placement setting&amp;nbsp; for all the clients and the number of maltreatments in each of the five setting and divide the latter by the former to get the rates.&amp;nbsp; Can I do this with the long format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;All can be done with a long data set, code provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; . The method of cleaning up depends on your knowledge of the data, and so you have to decide what gaps to fix, what overlaps to fix, and what is the proper method of fixing them, but the coding which we can help you with is much simpler with a long data set.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 21:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773777#M245862</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-12T21:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773792#M245871</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;!&amp;nbsp; I have thousands of IDs each with tens of events...so this is going to be ugly any way I look at it. But if I do the long method you say I should be able to trim overlaps and fill in gaps without going to wide?&amp;nbsp; So I will use your original code without the tabular format.&amp;nbsp; Would you object, if I have problems trying to fix gaps and overlaps, if I ask for further help?&amp;nbsp; Should I just post it here or create a new thread?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Marc&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 23:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773792#M245871</guid>
      <dc:creator>ModeratelyWise</dc:creator>
      <dc:date>2021-10-12T23:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773794#M245872</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;.&amp;nbsp; I will probably have to create a new thread as I plan on using&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;'s code to make the dataset long and have a row for each day for each client event.&amp;nbsp; &amp;nbsp;Which I imaging is going to be very long indeed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 23:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773794#M245872</guid>
      <dc:creator>ModeratelyWise</dc:creator>
      <dc:date>2021-10-12T23:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date-based arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773795#M245873</link>
      <description>Yeah, I used to explode it out to a day each as well but have found some interesting ways around this that are more efficient. &lt;BR /&gt;&lt;BR /&gt;One is to mark each entry/exit and then add/subtract as you go through events instead which was a technique I learned from R to do this but haven't had a chance to try it out in SAS. It's significantly more efficient than creating a record for each day. &lt;BR /&gt;&lt;BR /&gt;Instead, I would suggest starting a new thread with what you're trying to accomplish and letting some of the people here suggest approaches that will work? Create some small datasets that you can share that illustrate your problem and what you want to achieve and post those to get a really good answer quickly. Coming up with that REPREX (reproduceable example) step is key to this process. 80% of the time when I'm doing this, I usually figure out the solution before I post it. &lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2021 23:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-based-arrays/m-p/773795#M245873</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-12T23:14:50Z</dc:date>
    </item>
  </channel>
</rss>

