<?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 What is NADIR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-NADIR/m-p/962205#M375047</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand NADIR concept. I think NADIR is lowest overserved value up to a given time point and we need to use retain instead of min function to ensure time dependent accuracy and&amp;nbsp;update progressively, preserving the visit sequence. But In below dataset nadir should be 40 at Week_1 for subject 101 but I got 50 by using below provided code. Is it 40 or 50 at Week_1 and if it is 50 why? I have tried 2 different codes and I am talking about want1 program. Let me know if there are any mistake in both programs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA have;
    INPUT usubjid $1-3 avisit $5-13 adt $14-23 trtsdt $24-33 aval postbfl avisitn base;
    DATALINES;
101 Baseline 01JAN2024 05JAN2024 50 0 0 50
101 Week_1   08JAN2024 05JAN2024 40 1 1 50
101 Week_2   15JAN2024 05JAN2024 60 1 2 50
101 Week_3   22JAN2024 05JAN2024 30 1 3 50
101 Week_4   29JAN2024 05JAN2024 35 1 4 50
102 Baseline 02FEB2024 07FEB2024 70 0 0 70
102 Week_1   09FEB2024 07FEB2024 65 1 1 70
102 Week_2   16FEB2024 07FEB2024 80 1 2 70
102 Week_3   23FEB2024 07FEB2024 60 1 3 70
102 Week_4   01MAR2024 07FEB2024 75 1 4 70
;
RUN;
proc sort; by usubjid postbfl avisitn; run;

data want1;
	retain lag_aval nadir;
	set have;
	by usubjid postbfl;
	if first.usubjid then nadir=.;
	lag_aval=lag(aval);
	if postbfl then do;
		if first.postbfl then nadir=base;
		else nadir=min(nadir,lag_aval);
	end;
	chg=aval-nadir;
	pchgndr=chg/nadir*100;
run;

Data want2;
	Retain nadir prevval;
	Set have;
	By usubjid avisitn aval;
	If first.usubjid then do;
	Prevval = aval;
	Nadir = aval;
	End;
	Else do;
	If prevval ne . then nadir = min(prevval,nadir);
	Else if prevval = . then nadir =aval;
	Prevval = aval;
	End;
	chg=aval-nadir;
	If nmiss(aval, nadir) = 0 and nadir &amp;gt; 0 then pchgndr = round((aval-nadir)/nadir * 100, 0.1);
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NADIR.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105507i47F79D4007F86DB2/image-size/large?v=v2&amp;amp;px=999" role="button" title="NADIR.png" alt="NADIR.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chinna&lt;/P&gt;</description>
    <pubDate>Wed, 19 Mar 2025 11:03:50 GMT</pubDate>
    <dc:creator>chinna0369</dc:creator>
    <dc:date>2025-03-19T11:03:50Z</dc:date>
    <item>
      <title>What is NADIR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-NADIR/m-p/962205#M375047</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand NADIR concept. I think NADIR is lowest overserved value up to a given time point and we need to use retain instead of min function to ensure time dependent accuracy and&amp;nbsp;update progressively, preserving the visit sequence. But In below dataset nadir should be 40 at Week_1 for subject 101 but I got 50 by using below provided code. Is it 40 or 50 at Week_1 and if it is 50 why? I have tried 2 different codes and I am talking about want1 program. Let me know if there are any mistake in both programs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA have;
    INPUT usubjid $1-3 avisit $5-13 adt $14-23 trtsdt $24-33 aval postbfl avisitn base;
    DATALINES;
101 Baseline 01JAN2024 05JAN2024 50 0 0 50
101 Week_1   08JAN2024 05JAN2024 40 1 1 50
101 Week_2   15JAN2024 05JAN2024 60 1 2 50
101 Week_3   22JAN2024 05JAN2024 30 1 3 50
101 Week_4   29JAN2024 05JAN2024 35 1 4 50
102 Baseline 02FEB2024 07FEB2024 70 0 0 70
102 Week_1   09FEB2024 07FEB2024 65 1 1 70
102 Week_2   16FEB2024 07FEB2024 80 1 2 70
102 Week_3   23FEB2024 07FEB2024 60 1 3 70
102 Week_4   01MAR2024 07FEB2024 75 1 4 70
;
RUN;
proc sort; by usubjid postbfl avisitn; run;

data want1;
	retain lag_aval nadir;
	set have;
	by usubjid postbfl;
	if first.usubjid then nadir=.;
	lag_aval=lag(aval);
	if postbfl then do;
		if first.postbfl then nadir=base;
		else nadir=min(nadir,lag_aval);
	end;
	chg=aval-nadir;
	pchgndr=chg/nadir*100;
run;

Data want2;
	Retain nadir prevval;
	Set have;
	By usubjid avisitn aval;
	If first.usubjid then do;
	Prevval = aval;
	Nadir = aval;
	End;
	Else do;
	If prevval ne . then nadir = min(prevval,nadir);
	Else if prevval = . then nadir =aval;
	Prevval = aval;
	End;
	chg=aval-nadir;
	If nmiss(aval, nadir) = 0 and nadir &amp;gt; 0 then pchgndr = round((aval-nadir)/nadir * 100, 0.1);
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NADIR.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105507i47F79D4007F86DB2/image-size/large?v=v2&amp;amp;px=999" role="button" title="NADIR.png" alt="NADIR.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chinna&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 11:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-NADIR/m-p/962205#M375047</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2025-03-19T11:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is NADIR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-NADIR/m-p/962258#M375059</link>
      <description>&lt;P&gt;I presume that, for each week, you want nadir to report the lowest weekly value of AVAL up through the week in hand.&amp;nbsp; If so, then you can use the "retain nadir" statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by usubjid;
  retain nadir;
  if first.usubjid then nadir=aval;
  else nadir=min(aval,nadir);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As each new observation is read, nadir has the lowest aval through all preceding weeks, which then is compared to the current aval.&amp;nbsp; Of course, for the beginning of each usubjid, nadir is set to aval.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 17:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-NADIR/m-p/962258#M375059</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2025-03-19T17:06:02Z</dc:date>
    </item>
  </channel>
</rss>

