<?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: Coding efficient using multiple conditions with random number generation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479976#M123990</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Integer documentation said, it requires SAS 9.4 M4 but mine is only 9.4 M1. I tried 'integer' and it failed.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas version.png" style="width: 477px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21890i45E595BBE4696D85/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas version.png" alt="sas version.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 17:33:12 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2018-07-20T17:33:12Z</dc:date>
    <item>
      <title>Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479943#M123960</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;
&lt;P&gt;Since my ultimate goal is to calculate survival time (date of death-date of diagnosis)&amp;nbsp; I can't afford to&amp;nbsp;ignore missing month and day of diagnosis. Year of diagnosis&amp;nbsp;variable has no missing.&amp;nbsp; 'date of death' variable is complete and missing for patients alive. The goal here is to get the job done but nothing complex., like&amp;nbsp;involving multiple imputation et.c.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find my approach below does the job but too sloppy and many reducible&amp;nbsp;lines, I guess. There must be more efficient way writing this code. Right? All the conditions needed&amp;nbsp;to be&amp;nbsp;accounted are&amp;nbsp;specified before %randbetween.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot. &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 id date_of_diagnosis_dd date_of_diagnosis_mm date_of_diagnosis_yyyy date_of_death_dd date_of_death_mm date_of_death_yyyy;
cards;
1	99	8	2004    .   .   .  
2	99	99	2010	1	3	2013
3	99	99	2014	21	4	2014
4	99	99	2008	25	10	2008
5	99	99	2012    .   .   .
6	99	99	2010    .   .   .
4	99	2	2008	25	10	2008
;
	

%macro RandBetween(min, max);
   (&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))
%mend;

data have1; set have; 
do i=1 to 12; 
if date_of_death_mm ne . and date_of_diagnosis_yyyy=date_of_death_yyyy and date_of_diagnosis_mm=99  
then date_of_diagnosis_mm = %RandBetween(1, date_of_death_mm);
end;
drop i; 
run; 

data have2; set have1;
do i=1 to 12;
if date_of_death_mm ne . and date_of_diagnosis_yyyy ne date_of_death_yyyy and date_of_diagnosis_mm=99  
then date_of_diagnosis_mm = %RandBetween(1,12);
end;
drop i; 
run; 

data have3; set have2;
do i=1 to 12; 
if date_of_diagnosis_mm=99 
then date_of_diagnosis_mm = %RandBetween(1,12); 
end;
drop i; 
run; 

data have4; set have3;
do i=1 to 12; 
if date_of_diagnosis_dd=99 and date_of_diagnosis_mm ne 2 
then date_of_diagnosis_dd = %RandBetween(1,30); 
end;
if date_of_diagnosis_dd=99 and date_of_diagnosis_mm=2 
then date_of_diagnosis_dd = %RandBetween(1,28); 
drop i; 
run; 

proc freq data=have4;
tables date_of_diagnosis_dd date_of_diagnosis_mm;
run; 

data have5; set have4;
date_of_diagnosis=mdy(date_of_diagnosis_mm,date_of_diagnosis_dd,date_of_diagnosis_yyyy);
date_of_death=mdy(date_of_death_mm, date_of_death_dd, date_of_death_yyyy);
date_of_death1=date_of_death;
if date_of_death1=. then date_of_death1=20453;
survival_duration=sum(date_of_death1-date_of_diagnosis);
run; 


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 16:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479943#M123960</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T16:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479950#M123967</link>
      <description>&lt;P&gt;Why do you discard 11 results of the rand function and keep only every 12th? Because that's the only thing your do loops do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction: since the first iteration of the do loop changes the month from 99 to something else, the next 11 iterations won't do anything.&amp;amp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479950#M123967</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-20T17:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479952#M123969</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just changed 'do i=1 to 12' to 'do i=1 to 31' when it comes to rand function for date_of_diagnosis_dd.&lt;/P&gt;
&lt;P&gt;Hope that solves the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to 31; 
if date_of_diagnosis_dd=99 and date_of_diagnosis_mm ne 2 
then date_of_diagnosis_dd = %RandBetween(1,30); 
end;
if date_of_diagnosis_dd=99 and date_of_diagnosis_mm=2 
then date_of_diagnosis_dd = %RandBetween(1,28); 
drop i;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479952#M123969</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T17:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479955#M123972</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just changed 'do i=1 to 12' to 'do i=1 to 31' when it comes to rand function for date_of_diagnosis_dd.&lt;/P&gt;
&lt;P&gt;Hope that solves the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to 31; 
if date_of_diagnosis_dd=99 and date_of_diagnosis_mm ne 2 
then date_of_diagnosis_dd = %RandBetween(1,30); 
end;
if date_of_diagnosis_dd=99 and date_of_diagnosis_mm=2 
then date_of_diagnosis_dd = %RandBetween(1,28); 
drop i;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Only makes it worse. After iteration 1, date_of_diagnosis_dd won't be 99 anymore, so iteration 2 to 31 is just wasted time.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479955#M123972</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-20T17:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479957#M123974</link>
      <description>Please show me how if you will. I'm not familiar to Rand.</description>
      <pubDate>Fri, 20 Jul 2018 17:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479957#M123974</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T17:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479968#M123984</link>
      <description>&lt;P&gt;In the first iteration of the do loop, you set the dd variable to something else if it is 99. Since then the check for 99 cannot be true, the other iterations of the do loop do nothing.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479968#M123984</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-20T17:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479970#M123986</link>
      <description>&lt;P&gt;You may need a more rigorous strategy before trying to program this.&amp;nbsp; If month/day of diagnosis is missing, you might still encounter year of diagnosis equal to year of death.&amp;nbsp; Randomly selecting the month/day of diagnosis could lead to the diagnosis being later than death.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479970#M123986</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-20T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479972#M123988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I have this condition set in the first code block when&amp;nbsp;diagnosis and date happens in same year, month of diagnosis would not take value greater than month of death.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to 12; 
if date_of_death_mm ne . and date_of_diagnosis_yyyy=date_of_death_yyyy and date_of_diagnosis_mm=99  
then date_of_diagnosis_mm = %RandBetween(1, date_of_death_mm);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479972#M123988</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T17:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479973#M123989</link>
      <description>&lt;P&gt;If you have SAS 9.4&amp;nbsp;I think you have access to the RAND Integer option, rather than your randbetween macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3 class="xis-title"&gt;Integer Distribution&lt;/H3&gt;
&lt;DIV id="p1ndsrfybb9299n1clt07skfgbgn" class="xis-topicContent"&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A class="ng-scope" tabindex="0" title="Description of syntax: x" href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0fpeei0opypg8n1b06qe4r040lv.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=ja#p0apmg258ye01hn1fr33alquaan8" rel="nofollow" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0fpeei0opypg8n1b06qe4r040lv.htm#p0apmg258ye01hn1fr33alquaan8"&gt;x&lt;/A&gt;&lt;/SPAN&gt;=&lt;SPAN class="xis-keyword"&gt;RAND&lt;/SPAN&gt;('INTEGER',&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A class="ng-scope" tabindex="0" title="Description of syntax: b" href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0fpeei0opypg8n1b06qe4r040lv.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=ja#n02a7pp5rnelrin1rm0hlse6ezg1" rel="nofollow" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0fpeei0opypg8n1b06qe4r040lv.htm#n02a7pp5rnelrin1rm0hlse6ezg1"&gt;a&lt;/A&gt;&lt;/SPAN&gt;,&lt;SPAN class="xis-argOptional"&gt;&amp;lt;&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A class="ng-scope" tabindex="0" title="Description of syntax: b" href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0fpeei0opypg8n1b06qe4r040lv.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=ja#n02a7pp5rnelrin1rm0hlse6ezg1" rel="nofollow" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0fpeei0opypg8n1b06qe4r040lv.htm#n02a7pp5rnelrin1rm0hlse6ezg1"&gt;b&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;)&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n13kx27kmukou5n1mfpnjijx5zic" class="xis-paragraph"&gt;&lt;SPAN class="xis-selection"&gt;Arguments&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV id="p0apmg258ye01hn1fr33alquaan8" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;x&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;is a random value from the discrete uniform distribution on a finite set of integers. If you specify one integer parameter,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;a&lt;/SPAN&gt;, then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;x&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is drawn uniformly at random from the set {1,2,…, a–1, a}. If you specify two integer parameters,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;b&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with a ≤ b, then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;x&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is drawn uniformly at random from the set {a, a+1,…, b–1, b}.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n1j89348z9ifxrn14sf6cstd0uuy" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;a&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;is an integer parameter. If you specify only one numeric parameter,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is an upper limit for the random values. If you specify two parameters,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a lower limit.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n02a7pp5rnelrin1rm0hlse6ezg1" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;b&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;is an integer parameter that specifies the upper limit for the random values.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479973#M123989</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-20T17:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479976#M123990</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Integer documentation said, it requires SAS 9.4 M4 but mine is only 9.4 M1. I tried 'integer' and it failed.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas version.png" style="width: 477px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21890i45E595BBE4696D85/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas version.png" alt="sas version.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479976#M123990</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T17:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479980#M123993</link>
      <description>&lt;P&gt;Run this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
date_of_death_mm = 11;
date_of_diagnosis_yyyy = 2017;
date_of_death_yyyy = 2017;
date_of_diagnosis_mm = 99;
do i=1 to 12; 
if date_of_death_mm ne . and date_of_diagnosis_yyyy=date_of_death_yyyy and date_of_diagnosis_mm=99  
then date_of_diagnosis_mm = %RandBetween(1, date_of_death_mm);
  put i=;
  put date_of_diagnosis_mm=;
end;
date_of_diagnosis_mm = 11;
do i=1 to 12; 
if date_of_death_mm ne . and date_of_diagnosis_yyyy=date_of_death_yyyy and date_of_diagnosis_mm=99  
then date_of_diagnosis_mm = %RandBetween(1, date_of_death_mm);
  put i=;
  put date_of_diagnosis_mm=;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and look at the log.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479980#M123993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-20T17:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479984#M123996</link>
      <description>&lt;P&gt;Oh no, month of diagnosis is taking same value of month of death &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/479984#M123996</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T17:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480011#M124010</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Hi Kurt, how about to physically subset the data to avoid 'if' conditions. and run RAND over individual datasets to stack afterwards?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 18:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480011#M124010</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T18:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480069#M124029</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183379"&gt;@pau13rown&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I ended up going the direction you suggested. Generating random months would cause too much variation when my survival duration unit is measured by days. Instead, I'm linking my data with missing dates to a diagnosis file of Medicaid and see if I can get some hints of diagnosis dates there.&lt;/P&gt;
&lt;P&gt;Thanks Paul!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 20:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480069#M124029</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-20T20:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480122#M124051</link>
      <description>&lt;P&gt;i deleted my comment when i realised you were restricting the random number (and thus you wouldn't get negative survival as i suggested). Your new approach sounds ideal ie informed as much as possible. I think in the industry it's not uncommon to replace missing days with 15, but that's when there's a decade between diagnosis and death. With shorter survival, as you say, the impact of how missings are handled is more apparent&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 06:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480122#M124051</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-07-21T06:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480128#M124055</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Hi Kurt, how about to physically subset the data to avoid 'if' conditions. and run RAND over individual datasets to stack afterwards?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The problem are the do loops that serve no purpose (as demonstrated). Remove them. And you can do all the corrective measures in one data step.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 08:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480128#M124055</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-21T08:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Coding efficient using multiple conditions with random number generation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480151#M124066</link>
      <description>your conceptually wired comments are very interesting to me</description>
      <pubDate>Sat, 21 Jul 2018 14:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-efficient-using-multiple-conditions-with-random-number/m-p/480151#M124066</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-21T14:23:10Z</dc:date>
    </item>
  </channel>
</rss>

