<?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: Number of missing and location of missing across rows in repeated measurement data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538461#M148251</link>
    <description>Amazing! Thanks a lot. Updated the post again on 99 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Mon, 25 Feb 2019 21:56:21 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2019-02-25T21:56:21Z</dc:date>
    <item>
      <title>Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538433#M148232</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to know how many missing information each patient has and at what location? For example, PAT_ID=3 had missing at three occasions (Count_Missing=3) corresponding to his/her first, third and fourth visits (Location_Missing=1,0,3,4). Missing data is denoted as 99. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you please help solve this problem? The output I want are the the last two columns in mock data: Count_Missing and Location_missing. The output can be presented differently as long as rows are marked up in meaningful ways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks millions in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE; 
INPUT PAT_ID	date_visit	HB1	COUNT_ID	Count_Missing	Location_Missing;
CARDS;
1	15370	99	4	1	1
1	15824	12.1	4	1	0
1	16643	11	4	1	0
1	16820	11.6	4	1	0
2	15377	99	3	2	1
2	15888	99	3	2	2
2	16413	13.6	3	2	0
3	16029	99	4	3	1
3	16399	12.8	4	3	0
3	16587	99	4	3	3
3	16771	99	4	3	4
4	16561	12.6	4	3	0
4	16749	99	4	3	2
4	17099	99	4	3	3
4	17301	99	4	3	4&lt;/CODE&gt;&amp;nbsp;&lt;BR /&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 21:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538433#M148232</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-02-25T21:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538451#M148242</link>
      <description>What do you want as output?</description>
      <pubDate>Mon, 25 Feb 2019 21:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538451#M148242</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-25T21:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538454#M148245</link>
      <description>&lt;P&gt;The columns in the mock data: Count_Missing, Location_Missing. Sorry for ambiguity. I'll add this info in the post.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 21:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538454#M148245</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-02-25T21:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538459#M148249</link>
      <description>&lt;P&gt;99s are missing. That's a key piece of information you missed as well.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a DoW loop to calculate the number of missing and then use the standard data step to do the counter identification.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

do n=1 by 1 until (last.pat_id);
    set have (rename=(count_missing =want1 location_missing=want2));
	by pat_id;
	if first.pat_id then count_missing = 0;
	if hb1=99 then count_missing+1;
end;


do until(last.pat_id);
	set have (rename=(count_missing =want1 location_missing=want2));
	by pat_id;

	if first.pat_id then counter=1;
	else counter+1;

	if hb1=99 then location_missing=counter;
	else location_missing = 0;
	output;
end;

drop counter; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&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;The columns in the mock data: Count_Missing, Location_Missing. Sorry for ambiguity. I'll add this info in the post.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 21:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538459#M148249</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-25T21:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538461#M148251</link>
      <description>Amazing! Thanks a lot. Updated the post again on 99 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 25 Feb 2019 21:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538461#M148251</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-02-25T21:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538463#M148252</link>
      <description>&lt;P&gt;Since we count_id in the incoming dataset, one pass should do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE; 
INPUT PAT_ID	date_visit	HB1	COUNT_ID;*	Count_Missing	Location_Missing;
format date_visit date9.;
CARDS;
1	15370	99	4	1	1
1	15824	12.1	4	1	0
1	16643	11	4	1	0
1	16820	11.6	4	1	0
2	15377	99	3	2	1
2	15888	99	3	2	2
2	16413	13.6	3	2	0
3	16029	99	4	3	1
3	16399	12.8	4	3	0
3	16587	99	4	3	3
3	16771	99	4	3	4
4	16561	12.6	4	3	0
4	16749	99	4	3	2
4	17099	99	4	3	3
4	17301	99	4	3	4 
;

data want;
if 0 then set have;
Count_Missing=0;
do _n_=1 by 1 until(last.pat_id);
set have;
by pat_id;
Count_Missing+(hb1=99);
if  hb1=99 then Location_Missing=_n_;
else Location_Missing=0;
output;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Feb 2019 21:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538463#M148252</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-25T21:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538748#M148315</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wantreeza_novino.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27509i62F6D7C606833F4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="wantreeza_novino.png" alt="wantreeza_novino.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Two approaches are not in agreement. Desired output was Reeza's version. &lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 18:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538748#M148315</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-02-26T18:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538749#M148316</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp; Hmm good catch and my poor attention to detail. I think in that case, you would need a double pass,&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 PAT_ID	date_visit	HB1	COUNT_ID;*	Count_Missing	Location_Missing;
format date_visit date9.;
CARDS;
1	15370	99	4	1	1
1	15824	12.1	4	1	0
1	16643	11	4	1	0
1	16820	11.6	4	1	0
2	15377	99	3	2	1
2	15888	99	3	2	2
2	16413	13.6	3	2	0
3	16029	99	4	3	1
3	16399	12.8	4	3	0
3	16587	99	4	3	3
3	16771	99	4	3	4
4	16561	12.6	4	3	0
4	16749	99	4	3	2
4	17099	99	4	3	3
4	17301	99	4	3	4 
;

data want;
if 0 then set have;
Count_Missing=0;
do until(last.pat_id);
set have;
by pat_id;
Count_Missing+(hb1=99);
end;
do _n_=1 by 1 until(last.pat_id);
set have;
by pat_id;
Location_Missing=(hb1=99)*_n_;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let me think through a single pass . Sorry about that. My sincere apologies&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 18:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538749#M148316</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-26T18:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Number of missing and location of missing across rows in repeated measurement data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538752#M148318</link>
      <description>Awesome. We're all multi-tasking, I guess &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks a lot for help.</description>
      <pubDate>Tue, 26 Feb 2019 18:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-missing-and-location-of-missing-across-rows-in/m-p/538752#M148318</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-02-26T18:52:05Z</dc:date>
    </item>
  </channel>
</rss>

