<?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: Calculate the frequency of percent change based on the weight. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808381#M318764</link>
    <description>&lt;P&gt;One would need to see the log with the code that generated the message you report, but you haven't provided it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this is a good opportunity to see the value of the log.&amp;nbsp; You report the following message:&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#0000FF"&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;Each place is given by: (Number of times) at (Line):(Column).&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;4 at 65:6&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;4 at 65:61&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This means you should look at the line identified as line 65 in your log.&amp;nbsp; The statement there is presumably calculating a value, but one or more of the inputs to that calulation is a missing value.&amp;nbsp; Also note that this happens exactly 4 times.&amp;nbsp; All the rest of your observations did not have the problem, i.e. they did not have to base a calculation on a missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I notice that the 4 observations for ID=2 contain NO observations with diagnosis=1, so any calculation for ID=2 based on the date of diagnosis would generate the above message.&amp;nbsp; So you could avoid that result by putting the calculation in the THEN clause of an &lt;EM&gt;&lt;STRONG&gt;IF not missing(diag_date) THEN ....&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt; statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, what do you want to do in the WANT dataset for&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Any ID with not diagnosis date&lt;/LI&gt;
&lt;LI&gt;Any ID with a diagnosis date, but not test observations between exactly 2 and 4 months prior.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Apr 2022 18:41:51 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-04-18T18:41:51Z</dc:date>
    <item>
      <title>Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808068#M318624</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to calculate the frequency of patients who had &amp;gt;10% weight loss among 2 weights measured between 2-4 months before diagnosis. I have attached the pseudo-data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each patient has multiple visits with weight measurements. Their diagnosis of the disease is marked by "1" in the diagnosis column, and the date of encounter is the "dateoftest". I am trying to look at a 2-4 months window before the diagnosis date (diagnosis = 1), pull at least 2 weight measures, and compare if there is a &amp;gt;10% weight loss between those two weight measures. If &amp;gt;10% weight loss then flag the patients. There should be two wt measured between 2-4 months before diagnosis, If only 1 wt measure then it is marked as missing. Or if no weight is measured, it is also marked as missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, calculate the frequency of patients with &amp;gt;10% weight loss and those with missing weight within 2-4 months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would really appreciate the help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Sandyzman&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 17:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808068#M318624</guid>
      <dc:creator>sandyzman1</dc:creator>
      <dc:date>2022-04-15T17:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808070#M318625</link>
      <description>&lt;P&gt;You mention "at least" two weight measure in the 4-month-prior to 2-month-prior time period.&amp;nbsp; Then later, you say that there should be 2 such tests.&amp;nbsp; So are you really excluding the possibiliyt of more than 2 visits in that window?&amp;nbsp; If not, then the case of more than two qualifying tests, which weights should be used to measure weight loss?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, what is "two months before"&amp;nbsp; Is April15, 2022 two months before June 10, 2022?&amp;nbsp; &amp;nbsp; Similarly, is April 15, 2022 more than four months before August 17, 2022?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 17:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808070#M318625</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-15T17:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808079#M318630</link>
      <description>Hi mkeintz,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply. I meant at least 2 or more weight measures before diagnosis (1) and see if there is any of the weight change (within that window) is more than 10% wt loss. Most likely, the extreme 2 wt measure (farthest from diagnosis and closest to diagnosis) will work. or, if possible, any wt loss in between is more than 10% loss.&lt;BR /&gt;&lt;BR /&gt;-  The two months before June 10, 2022, include wt measure after April 10, 2022. So, April 15, 2022, is within 2 months&lt;BR /&gt;-  April 17, 2022, and after is four months before August 17, 2022, so April 15, 2022, is more than four months.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sandyzman1</description>
      <pubDate>Fri, 15 Apr 2022 18:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808079#M318630</guid>
      <dc:creator>sandyzman1</dc:creator>
      <dc:date>2022-04-15T18:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808091#M318641</link>
      <description>&lt;P&gt;I am not going to do the work of converting your XLSX file into a SAS data set, so the following code is untested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=nxt_: );

  merge have (keep=id dateoftest diagnosis rename=(dateoftest=diag_date) where=(diagnosis=1)
        have ;
  by id;
  set have (firstobs=2 keep=id dateoftest rename=(id=nxt_id dateoftest=nxt_date));

  retain wgt1 wgt2 .;
  if first.id then call missing(of wgt:);

  if intnx('month',diag_date,-4,'sameday') &amp;lt;= dateoftest &amp;lt;= intnx('month',diag_date,-2,'sameday');

  if wgt1=. then wgt1=weight;
  else wgt2=coalesce(weight,wgt2);

  if intck('month',nxt_date,diag_date,'c')&amp;gt;2;   **See editted note below**;
  if nmiss(wgt1,wgt2)=0 then wgt_change_ratio= wgt2/wgt1-1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The program assumes your data in dataset HAVE is sorted by ID/DATEOFTEST.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It merges the diagnosis date record (when diagnosis=1) will all the records for a given id.&amp;nbsp; And it keeps only those whose dates fall within the 4-2 month prior window, keeping the earliest weight in the window as WGT1 and the latest within-window weight as WGT2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once the within-windows observations are exhausted (i.e. the next obs is outside the window), the weight change is calculated and the data is output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted Note: Corrected the 4th argument to intck from 's' to 'c'.&amp;nbsp; But the code is still untested.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Apr 2022 17:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808091#M318641</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-16T17:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808178#M318665</link>
      <description>Hi mkeintz,&lt;BR /&gt;&lt;BR /&gt;Thank you so much for the help. I really appreciate it. However, when I imported the xlsx file into SAS and ran the code. I got the following error. I couldn't figure out what is the issue. Would you please suggest how to resolve these issues? Thanks.&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',18235,18270,'s') at line 84 column 6.&lt;BR /&gt;id=1 diag_date=01/08/2010 diagnosis=0 dateoftest=11/03/2009 weight=99 FIRST.id=0 LAST.id=0 nxt_id=1&lt;BR /&gt;nxt_date=12/04/2009 wgt1=99 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=2&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',17938,18003,'s') at line 84 column 6.&lt;BR /&gt;id=3 diag_date=04/16/2009 diagnosis=0 dateoftest=02/09/2009 weight=119 FIRST.id=1 LAST.id=0 nxt_id=3&lt;BR /&gt;nxt_date=02/10/2009 wgt1=119 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=12&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',18003,18003,'s') at line 84 column 6.&lt;BR /&gt;id=3 diag_date=04/16/2009 diagnosis=0 dateoftest=02/10/2009 weight=. FIRST.id=0 LAST.id=0 nxt_id=3&lt;BR /&gt;nxt_date=04/16/2009 wgt1=119 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=13&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',21266,21289,'s') at line 84 column 6.&lt;BR /&gt;id=4 diag_date=04/15/2018 diagnosis=0 dateoftest=02/10/2018 weight=. FIRST.id=1 LAST.id=0 nxt_id=4&lt;BR /&gt;nxt_date=03/23/2018 wgt1=. wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=18&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',20131,20201,'s') at line 84 column 6.&lt;BR /&gt;id=5 diag_date=04/23/2015 diagnosis=0 dateoftest=01/03/2015 weight=120 FIRST.id=0 LAST.id=0 nxt_id=5&lt;BR /&gt;nxt_date=02/12/2015 wgt1=120 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=24&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',20201,20201,'s') at line 84 column 6.&lt;BR /&gt;id=5 diag_date=04/23/2015 diagnosis=0 dateoftest=02/12/2015 weight=95 FIRST.id=0 LAST.id=0 nxt_id=5&lt;BR /&gt;nxt_date=04/23/2015 wgt1=120 wgt2=95 wgt_change_ratio=. _ERROR_=1 _N_=25&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',19401,19471,'s') at line 84 column 6.&lt;BR /&gt;id=6 diag_date=04/23/2013 diagnosis=0 dateoftest=01/03/2013 weight=80 FIRST.id=1 LAST.id=0 nxt_id=6&lt;BR /&gt;nxt_date=02/12/2013 wgt1=80 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=29&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',19471,19471,'s') at line 84 column 6.&lt;BR /&gt;id=6 diag_date=04/23/2013 diagnosis=0 dateoftest=02/12/2013 weight=79 FIRST.id=0 LAST.id=0 nxt_id=6&lt;BR /&gt;nxt_date=04/23/2013 wgt1=80 wgt2=79 wgt_change_ratio=. _ERROR_=1 _N_=30&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',21227,21297,'s') at line 84 column 6.&lt;BR /&gt;id=7 diag_date=04/23/2018 diagnosis=0 dateoftest=01/03/2018 weight=80 FIRST.id=1 LAST.id=0 nxt_id=7&lt;BR /&gt;nxt_date=02/12/2018 wgt1=80 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=35&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',21297,21297,'s') at line 84 column 6.&lt;BR /&gt;id=7 diag_date=04/23/2018 diagnosis=0 dateoftest=02/12/2018 weight=79 FIRST.id=0 LAST.id=0 nxt_id=7&lt;BR /&gt;nxt_date=04/23/2018 wgt1=80 wgt2=79 wgt_change_ratio=. _ERROR_=1 _N_=36&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',19331,19366,'s') at line 84 column 6.&lt;BR /&gt;id=8 diag_date=01/08/2013 diagnosis=0 dateoftest=11/03/2012 weight=99 FIRST.id=0 LAST.id=0 nxt_id=8&lt;BR /&gt;nxt_date=12/04/2012 wgt1=99 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=42&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;sandyzman1&lt;BR /&gt;</description>
      <pubDate>Sat, 16 Apr 2022 15:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808178#M318665</guid>
      <dc:creator>sandyzman1</dc:creator>
      <dc:date>2022-04-16T15:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808182#M318667</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188593"&gt;@sandyzman1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi mkeintz,&lt;BR /&gt;&lt;BR /&gt;Thank you so much for the help. I really appreciate it. However, when I imported the xlsx file into SAS and ran the code. I got the following error. I couldn't figure out what is the issue. Would you please suggest how to resolve these issues? Thanks.&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',18235,18270,'s') at line 84 column 6.&lt;BR /&gt;id=1 diag_date=01/08/2010 diagnosis=0 dateoftest=11/03/2009 weight=99 FIRST.id=0 LAST.id=0 nxt_id=1&lt;BR /&gt;nxt_date=12/04/2009 wgt1=99 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=2&lt;BR /&gt;NOTE: Invalid argument to function INTCK('month',17938,18003,'s') at line 84 column 6.&lt;BR /&gt;id=3 diag_date=04/16/2009 diagnosis=0 dateoftest=02/09/2009 weight=119 FIRST.id=1 LAST.id=0 nxt_id=3&lt;BR /&gt;nxt_date=02/10/2009 wgt1=119 wgt2=. wgt_change_ratio=. _ERROR_=1 _N_=12&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;sandyzman1&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is one of the consequences of submitting untested code, which is my usual response in the absence of sample data in the form of a working data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will edit my earlier response to change the "S" parameter in the intck function to "C".&amp;nbsp; &amp;nbsp;The "S" parameter serves an analogous role in the INTNX function to the "C" that I should have used in the INTCK function.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Apr 2022 18:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808182#M318667</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-16T18:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808332#M318738</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi mkeintz,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you so much for your response. I understand that I should have originally attached the working dataset. I thought the file would be too long to attach. However, I am still getting the error message, and I am new to SAS so I don't totally understand what I going on. I got the following error now.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#0000FF"&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Each place is given by: (Number of times) at (Line):(Column).&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;4 at 65:6&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;4 at 65:61&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;I have attached the SAS data file and also copied the dataline (if the file doesn't work).&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; test;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;infile&lt;/SPAN&gt; datalines &lt;SPAN class="s2"&gt;delimiter&lt;/SPAN&gt;=&lt;SPAN class="s3"&gt;','&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;input&lt;/SPAN&gt; id dateoftest :&lt;SPAN class="s4"&gt;mmddyy8.&lt;/SPAN&gt; diagnosis weight;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="s5"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;datalines&lt;SPAN class="s5"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;1, 4/8/2009, 0, 98,&lt;/P&gt;
&lt;P class="p1"&gt;1, 11/3/2009, 0, 99,&lt;/P&gt;
&lt;P class="p1"&gt;1, 12/4/2009, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;1, 1/8/2010, 1, 89,&lt;/P&gt;
&lt;P class="p1"&gt;1, 3/24/2010, 0, 76,&lt;/P&gt;
&lt;P class="p1"&gt;1, 4/4/2011, 0, 75,&lt;/P&gt;
&lt;P class="p1"&gt;1, 7/14/2011, 0, 70,&lt;/P&gt;
&lt;P class="p1"&gt;2, 4/23/2016, 0, 122,&lt;/P&gt;
&lt;P class="p1"&gt;2, 5/20/2016, 0, 124,&lt;/P&gt;
&lt;P class="p1"&gt;2, 7/10/2016, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;2, 9/25/2017, 0, 120,&lt;/P&gt;
&lt;P class="p1"&gt;3, 2/9/2009, 0, 119,&lt;/P&gt;
&lt;P class="p1"&gt;3, 2/10/2009, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;3, 4/16/2009, 1, 120,&lt;/P&gt;
&lt;P class="p1"&gt;3, 5/23/2009, 0, 105,&lt;/P&gt;
&lt;P class="p1"&gt;3, 6/17/2010, 0, 98,&lt;/P&gt;
&lt;P class="p1"&gt;3, 5/12/2011, 0, 94,&lt;/P&gt;
&lt;P class="p1"&gt;4, 3/23/2018, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;4, 2/10/2018, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;4, 4/18/2018, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;4, 4/15/2018, 1, ,&lt;/P&gt;
&lt;P class="p1"&gt;4, 7/3/2019, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;5, 12/4/2014, 0, 130,&lt;/P&gt;
&lt;P class="p1"&gt;5, 1/3/2015, 0, 120,&lt;/P&gt;
&lt;P class="p1"&gt;5, 2/12/2015, 0, 95,&lt;/P&gt;
&lt;P class="p1"&gt;5, 4/23/2015, 1, 96,&lt;/P&gt;
&lt;P class="p1"&gt;5, 5/5/2015, 0, 87,&lt;/P&gt;
&lt;P class="p1"&gt;5, 8/9/2016, 0, 88,&lt;/P&gt;
&lt;P class="p1"&gt;6, 12/4/2013, 0, 98,&lt;/P&gt;
&lt;P class="p1"&gt;6, 1/3/2013, 0, 80,&lt;/P&gt;
&lt;P class="p1"&gt;6, 2/12/2013, 0, 79,&lt;/P&gt;
&lt;P class="p1"&gt;6, 4/23/2013, 1, 78,&lt;/P&gt;
&lt;P class="p1"&gt;6, 5/5/2013, 0, 75,&lt;/P&gt;
&lt;P class="p1"&gt;6, 8/9/2014, 0, 74,&lt;/P&gt;
&lt;P class="p1"&gt;7, 12/4/2018, 0, 81,&lt;/P&gt;
&lt;P class="p1"&gt;7, 1/3/2018, 0, 80,&lt;/P&gt;
&lt;P class="p1"&gt;7, 2/12/2018, 0, 79,&lt;/P&gt;
&lt;P class="p1"&gt;7, 4/23/2018, 1, 78,&lt;/P&gt;
&lt;P class="p1"&gt;7, 5/5/2018, 0, 75,&lt;/P&gt;
&lt;P class="p1"&gt;7, 8/9/2018, 0, 74,&lt;/P&gt;
&lt;P class="p1"&gt;8, 4/8/2012, 0, 140,&lt;/P&gt;
&lt;P class="p1"&gt;8, 11/3/2012, 0, 99,&lt;/P&gt;
&lt;P class="p1"&gt;8, 12/4/2012, 0, ,&lt;/P&gt;
&lt;P class="p1"&gt;8, 1/8/2013, 1, 89,&lt;/P&gt;
&lt;P class="p1"&gt;8, 3/24/2013, 0, 76,&lt;/P&gt;
&lt;P class="p1"&gt;8, 4/4/2013, 0, 75,&lt;/P&gt;
&lt;P class="p1"&gt;8, 7/14/2013, 0, 70,&lt;/P&gt;
&lt;P class="p1"&gt;;&lt;/P&gt;
&lt;P class="p3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s5"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p3"&gt;&lt;SPAN class="s5"&gt;I really appreciate your help. Thanks.&lt;BR /&gt;&lt;BR /&gt;Sandyzman1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 15:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808332#M318738</guid>
      <dc:creator>sandyzman1</dc:creator>
      <dc:date>2022-04-18T15:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808381#M318764</link>
      <description>&lt;P&gt;One would need to see the log with the code that generated the message you report, but you haven't provided it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this is a good opportunity to see the value of the log.&amp;nbsp; You report the following message:&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#0000FF"&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;Each place is given by: (Number of times) at (Line):(Column).&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;4 at 65:6&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;4 at 65:61&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This means you should look at the line identified as line 65 in your log.&amp;nbsp; The statement there is presumably calculating a value, but one or more of the inputs to that calulation is a missing value.&amp;nbsp; Also note that this happens exactly 4 times.&amp;nbsp; All the rest of your observations did not have the problem, i.e. they did not have to base a calculation on a missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I notice that the 4 observations for ID=2 contain NO observations with diagnosis=1, so any calculation for ID=2 based on the date of diagnosis would generate the above message.&amp;nbsp; So you could avoid that result by putting the calculation in the THEN clause of an &lt;EM&gt;&lt;STRONG&gt;IF not missing(diag_date) THEN ....&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt; statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, what do you want to do in the WANT dataset for&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Any ID with not diagnosis date&lt;/LI&gt;
&lt;LI&gt;Any ID with a diagnosis date, but not test observations between exactly 2 and 4 months prior.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 18:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808381#M318764</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-18T18:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808435#M318777</link>
      <description>I just wanted to create a flag for &amp;gt;10% weight loss within 2-4 months before the diagnosis of disease for each ID. &lt;BR /&gt;&lt;BR /&gt;1. If with no diagnosis date  then the flag will be 0&lt;BR /&gt;2. if any diagnosis date, but not test observation then flag = 0.&lt;BR /&gt;&lt;BR /&gt;Only those who meet the criteria will have a flag = 1. &lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;sandyzman1</description>
      <pubDate>Mon, 18 Apr 2022 21:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808435#M318777</guid>
      <dc:creator>sandyzman1</dc:creator>
      <dc:date>2022-04-18T21:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the frequency of percent change based on the weight.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808548#M318830</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks! Your code actually worked. I ran each line seperately and noticed that I need to change wgt2 into wgt1 in the line: wgt2=coalesce(weight,wgt2). When I did that I got what I wanted. For the future reference, I used your following code:&lt;BR /&gt;&lt;BR /&gt;data want ;&lt;BR /&gt;  merge have (keep=id dateoftest diagnosis rename=(dateoftest=diag_date) where=(diagnosis=1))&lt;BR /&gt;        have;&lt;BR /&gt;  by id;&lt;BR /&gt;  set have (firstobs=2 keep=id dateoftest rename=(id=nxt_id dateoftest=nxt_date));&lt;BR /&gt;  retain wgt1 wgt2 .;&lt;BR /&gt;  if first.id then call missing(of wgt:);&lt;BR /&gt;  if intnx('month',diag_date,-4,'sameday') &amp;lt;= dateoftest &amp;lt;= intnx('month',diag_date,-2,'sameday');&lt;BR /&gt;  if wgt1=. then wgt1=weight; &lt;BR /&gt;  else wgt2=coalesce(weight,wgt1);&lt;BR /&gt; * if intck('month',nxt_date,diag_date,'c')&amp;gt;2   **See editted note below**;&lt;BR /&gt;  if nmiss(wgt1,wgt2)=0 then wgt_change_ratio= wgt2/wgt1-1;&lt;BR /&gt;  if wgt_change_ratio ^=. and  wgt_change_ratio &amp;lt;= -0.1 then flag = 1;&lt;BR /&gt; else flag = 0;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;That was super helpful. Thank you so much for your help &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Sandyzman1&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Apr 2022 13:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-frequency-of-percent-change-based-on-the-weight/m-p/808548#M318830</guid>
      <dc:creator>sandyzman1</dc:creator>
      <dc:date>2022-04-19T13:10:03Z</dc:date>
    </item>
  </channel>
</rss>

