<?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: making a summarizing table from repeatedly measured data over time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516481#M139492</link>
    <description>That's true. What I want to know is the proportion of a subject that has at least one YES in v1 over the time period. Thanks.</description>
    <pubDate>Tue, 27 Nov 2018 21:11:21 GMT</pubDate>
    <dc:creator>asinusdk</dc:creator>
    <dc:date>2018-11-27T21:11:21Z</dc:date>
    <item>
      <title>making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516419#M139470</link>
      <description>&lt;P&gt;In a longitudinal data, the frequency can be calculated by proc freq, but what if I want to know whether a subject has a particular response or not over the time in a long format. I think it will be necessary to have a summarized table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I have a long format data like below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;time&lt;/TD&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;v1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;no&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;from this table, I want to know how many subjects (id) have at least one response (yes) for v1 over time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case v1 is shown in id 1 and id 3 so that will be 2. Is it necessary to have a table like below to obtain the results? If it's the case, could you please let me know the programming code? Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;total_v1&lt;/TD&gt;&lt;TD&gt;v1_freq&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 27 Nov 2018 17:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516419#M139470</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T17:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516421#M139471</link>
      <description>You can build on the approach used here. &lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Vertical-joining/m-p/504927" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Vertical-joining/m-p/504927&lt;/A&gt;</description>
      <pubDate>Tue, 27 Nov 2018 17:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516421#M139471</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-27T17:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516423#M139472</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input time	id	v1 $;
cards;
1	1	no
2	1	no
3	1	yes
4	1	yes
1	2	no
2	2	no
3	2	no
4	2	no
1	3	yes
2	3	no
3	3	no
4	3	no
;

data want;
do v1_freq=1 by 1  until(last.v1);
set have;
by id v1 notsorted;
end;
v1_freq=ifn(v1='yes',v1_freq,0);
keep id v1:;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Nov 2018 17:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516423#M139472</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T17:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516425#M139473</link>
      <description>&lt;P&gt;Thanks so much.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 17:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516425#M139473</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T17:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516456#M139488</link>
      <description>Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 27 Nov 2018 19:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516456#M139488</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T19:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516477#M139490</link>
      <description>&lt;P&gt;I tried the code and got the result like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;total_v1&lt;/TD&gt;&lt;TD&gt;v1_freq&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rather, what I wanted looks like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;total_v1&lt;/TD&gt;&lt;TD&gt;v1_freq&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;nodupkey didn't work here....&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 21:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516477#M139490</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T21:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516480#M139491</link>
      <description>&lt;P&gt;Ok, kindly clarify this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should a by group(id) have both no and yes, do you want only the counts of yes and ignore no?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 21:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516480#M139491</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T21:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516481#M139492</link>
      <description>That's true. What I want to know is the proportion of a subject that has at least one YES in v1 over the time period. Thanks.</description>
      <pubDate>Tue, 27 Nov 2018 21:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516481#M139492</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T21:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516487#M139495</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240083"&gt;@asinusdk&lt;/a&gt;&amp;nbsp;for clarifying&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input time	id	v1 $;
cards;
1	1	no
2	1	no
3	1	yes
4	1	yes
1	2	no
2	2	no
3	2	no
4	2	no
1	3	yes
2	3	no
3	3	no
4	3	no
;
proc sort data=have out=_have;
by id v1;
run;


data want;
set _have;
by id v1 ;
if first.v1 then v1_freq=1;
else v1_freq+1;
if last.id ;
v1_freq=ifn(v1='yes',v1_freq,0);
keep id v1:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Nov 2018 21:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516487#M139495</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T21:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516489#M139497</link>
      <description>Thank you so much. You saved my life.</description>
      <pubDate>Tue, 27 Nov 2018 21:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516489#M139497</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T21:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516490#M139498</link>
      <description>&lt;P&gt;That was a very minor change. I hope you are able to understand the change and follow the code. The sorting of NO and YES made it easy as YES in collating sequence will always be 2nd to NO and so when you process last.id (last obs of the group), it would always be YES if there were YES and NO in a by group and if it's only NO, it;s of course NO and it;s count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IFN function simply resets the NO count to zero to meet your requirement. Anyways, feel free to write back to us if you need any help. Cheers!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 21:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516490#M139498</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T21:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516493#M139500</link>
      <description>Thanks for the explanation! I'm trying to understand the logic.</description>
      <pubDate>Tue, 27 Nov 2018 21:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516493#M139500</guid>
      <dc:creator>asinusdk</dc:creator>
      <dc:date>2018-11-27T21:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516512#M139507</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240083"&gt;@asinusdk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;That's true. What I want to know is the proportion of a subject that has at least one YES in v1 over the time period. Thanks.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you want to be able to say 2/3 patients had at least yes at one point over the time period? If that's the case, you're better off using an indicator flag rather than a count.&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 time	id	v1 $;
cards;
1	1	no
2	1	no
3	1	yes
4	1	yes
1	2	no
2	2	no
3	2	no
4	2	no
1	3	yes
2	3	no
3	3	no
4	3	no
;
proc sort data=have out=_have;
by id descending v1;
run;


data want;
set _have;
by id descending v1 ;
flag=0;
if first.id and v1='yes' then flag=1;
if first.id then output;
run;

proc means data=want mean;
var flag;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be 66.67%, ie 2/3 have yes.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 22:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516512#M139507</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-27T22:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: making a summarizing table from repeatedly measured data over time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516518#M139512</link>
      <description>&lt;P&gt;I wanted to have some fun with proc sql&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input time	id	v1 $;
cards;
1	1	no
2	1	no
3	1	yes
4	1	yes
1	2	no
2	2	no
3	2	no
4	2	no
1	3	yes
2	3	no
3	3	no
4	3	no
;
proc sql;
create table want as
select distinct id ,v1, sum(v1='yes') as v1_freq
from have
group by id
having count(distinct v1)&amp;gt;=1 and v1='yes' or count(distinct v1)=1 and v1='no';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Nov 2018 23:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-a-summarizing-table-from-repeatedly-measured-data-over/m-p/516518#M139512</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T23:03:08Z</dc:date>
    </item>
  </channel>
</rss>

