<?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 Random Number generator to impute month and day as part of date question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70350#M15226</link>
    <description>I have a program to impute either a missing day or month and day using ranuni.  &lt;BR /&gt;
&lt;BR /&gt;
The problem is that the random date sometimes falls into a range that is impossible, ie. less than a start date.  &lt;BR /&gt;
&lt;BR /&gt;
Does anyone know of a way to restrict this randomization so that the imputed day/month is not less than the day/month of the start date if they fall within the same month/year ?  &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance !</description>
    <pubDate>Tue, 23 Mar 2010 17:58:03 GMT</pubDate>
    <dc:creator>statadm</dc:creator>
    <dc:date>2010-03-23T17:58:03Z</dc:date>
    <item>
      <title>Random Number generator to impute month and day as part of date question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70350#M15226</link>
      <description>I have a program to impute either a missing day or month and day using ranuni.  &lt;BR /&gt;
&lt;BR /&gt;
The problem is that the random date sometimes falls into a range that is impossible, ie. less than a start date.  &lt;BR /&gt;
&lt;BR /&gt;
Does anyone know of a way to restrict this randomization so that the imputed day/month is not less than the day/month of the start date if they fall within the same month/year ?  &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance !</description>
      <pubDate>Tue, 23 Mar 2010 17:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70350#M15226</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-03-23T17:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number generator to impute month and day as part of date question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70351#M15227</link>
      <description>You can use the INTNX function to set a low/high start/stop range within your code.&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
FORMAT LOWDATE HIDATE DATE9.;&lt;BR /&gt;
LOWDATE = INTNX('MONTH',TODAY(),-12,'SAMEDAY');&lt;BR /&gt;
HIDATE = INTNX('MONTH',TODAY(),12,'SAMEDAY');&lt;BR /&gt;
PUTLOG _ALL_;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Useful SAS support website reference on this topic:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/techsup/technote/ts668.pdf" target="_blank"&gt;http://support.sas.com/techsup/technote/ts668.pdf&lt;/A&gt;</description>
      <pubDate>Tue, 23 Mar 2010 18:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70351#M15227</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-23T18:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Random Number generator to impute month and day as part of date question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70352#M15228</link>
      <description>I believe the code below does what you're looking for:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  format StartDate RandomDate date9.;&lt;BR /&gt;
  StartDate=today();&lt;BR /&gt;
  DateRange=60;&lt;BR /&gt;
  do i=1 to 20;&lt;BR /&gt;
    /* RandomDate within range StartDate to Startdate+59 days */&lt;BR /&gt;
    RandomDate=Startdate+floor(ranuni(0)*DateRange);&lt;BR /&gt;
    put RandomDate=;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
If you need to calculate the date range more dynamically then look at Scott's code.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 24 Mar 2010 13:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-Number-generator-to-impute-month-and-day-as-part-of-date/m-p/70352#M15228</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-03-24T13:31:55Z</dc:date>
    </item>
  </channel>
</rss>

