title: I would need to valorise columns in SAS according to a specific condition of other columns. Can anyone help me?
body: <p>I need help with a SAS code.</p>
  <p>My table displays several contracts.
  There is a column <code>Expiring_Month</code>, telling on which month the contract expires.</p>
  <p>Plus, I have 4 variables <code>Amount_N</code>, <code>Amount_R</code>, <code>Amount_RT</code>, <code>Amount_NT</code> (each of these is divided for 12 months (so 48 columns), so they look like <code>Amount_202001_N</code>, <code>Amount_202002_N</code>, <code>Amount_202003_N</code> and so on till December). Moreover, there are other 4 columns <code>Amount_MIN_N</code>, <code>Amount_MIN_R</code>, <code>Amount_MIN_RT</code>, <code>Amount_MIN_NT</code>.</p>
  <p>Basically, <code>Amount_Min_N</code> exists only if <code>Amount_Min_R</code> does not exist (and viceversa), while, <code>Amount_2020XX_RT</code> and <code>Amount_2020XX_NT</code> are valorised until the month before the <code>Expiring_Month</code>.</p>
  <p>What I need to do is to give the value of <code>Amount_Min_RT</code> and <code>Amount_Min_NT</code> to the columns <code>Amount_2020XX_R</code>
  (i should actually give values for 9 (Sep) 10 (Oct), 11 (Nov) 12 (Dec) as I have already data till August).</p>
  <p>The first step I have done is the following (I only post Oct valorization, but i did for Nov and Dec):</p>
  <pre><code>data xox_sa_1;
  set xox_sa;
      *october;
      if (amount_min_n &gt; 0 and amount_min_r = .) then amount_202010_N = amount_min_n;
      if (amount_min_n = . and amount_min_r &gt; 0) then amount_202010_r = amount_min_r;
  run;
  </code></pre>
  <p>Then, if for example there is a contract expired on May, the <code>Amount_202005_RT</code> (or <code>Amount_202005_NT</code>, it depends on the case) does not get valorised, but the variable <code>Amount_202005_R</code> (and the following <code>Amount_202006_R</code>, and so on) should get valorised with the <code>Amount_Min_RT</code>/<code>Amount_Min_NT</code> values.</p>
  <p>I hope I made it clear ... does anyone have any idea?? I would need to take into consideration the expiring month, but I do not know how.</p>