<?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: Count Behaviors-Repeated Measures in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160559#M299647</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry then, I misunderstood your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The easiest that comes to my mind is first of all, sort data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=merged_visit2;&lt;/P&gt;&lt;P&gt;by patid visitnum pfsy6mo;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and create a variable with retain that count how many time this person has answered&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data aux_data;&lt;/P&gt;&lt;P&gt;set &lt;SPAN style="font-size: 13.3333330154419px;"&gt;merged_visit2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;by &lt;SPAN style="font-size: 13.3333330154419px;"&gt;patid visitnum pfsy6mo;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;retain num_answers;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;if first.patid then num_answers=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if pfs6ymo=1 then num_answers=num_answers+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if last.patid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;doing this, you will get a only record by patid with the number of questions answered. Then with a proc freq or with sql you can get the number of patients that answers question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To know who reported I guess that you can transpose this dataset using as column the visits and transposing the &lt;SPAN style="font-size: 13.3333330154419px;"&gt;pfsy6mo&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=merged_visit2 out=trans_data;&lt;/P&gt;&lt;P&gt;by patid;&lt;/P&gt;&lt;P&gt;id visitnum;&lt;/P&gt;&lt;P&gt;var pfsy6mo;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Feb 2015 07:20:56 GMT</pubDate>
    <dc:creator>arodriguez</dc:creator>
    <dc:date>2015-02-11T07:20:56Z</dc:date>
    <item>
      <title>Count Behaviors-Repeated Measures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160556#M299644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have repeated measures data (long format) and my outcome variable is binary 1=yes, 0=no. I am looking at factors associated with the outcome over time. What I want is how many participants reported the outcome at each visit, so some participants could have reported it at 1 visit, some at 2, 3, 4 visits, etc...I am not sure how to have SAS tell me this. Any advice is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 06:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160556#M299644</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2015-02-10T06:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count Behaviors-Repeated Measures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160557#M299645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use sql to know this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select distinct(visits), sum(binary_variable=1)&amp;nbsp; as result&lt;/P&gt;&lt;P&gt;from dataset&lt;/P&gt;&lt;P&gt;group by visit&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 14:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160557#M299645</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-02-10T14:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count Behaviors-Repeated Measures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160558#M299646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe I am running the code incorrectly but that code actually just gives me the same result as running a proc freq with a cross tab for visit and the outcome. So it esentially just tells me who reported the behavior and each visit. My original question maybe doesn't make sense but I want to try to figure out who reported the behavior at only 1 visit, who reported it at 2 visits, and who reported it at all visits...Does that make sense? Thank you for your help. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I used: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;distinct&lt;/SPAN&gt;(visitnum),sum(pfsy6mo=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;) &lt;SPAN style="color: #0433ff;"&gt;as&lt;/SPAN&gt; pfsycount&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;from&lt;/SPAN&gt; merged_visits2&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; visitnum;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 18:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160558#M299646</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2015-02-10T18:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count Behaviors-Repeated Measures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160559#M299647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry then, I misunderstood your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The easiest that comes to my mind is first of all, sort data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=merged_visit2;&lt;/P&gt;&lt;P&gt;by patid visitnum pfsy6mo;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and create a variable with retain that count how many time this person has answered&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data aux_data;&lt;/P&gt;&lt;P&gt;set &lt;SPAN style="font-size: 13.3333330154419px;"&gt;merged_visit2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;by &lt;SPAN style="font-size: 13.3333330154419px;"&gt;patid visitnum pfsy6mo;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;retain num_answers;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;if first.patid then num_answers=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if pfs6ymo=1 then num_answers=num_answers+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if last.patid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;doing this, you will get a only record by patid with the number of questions answered. Then with a proc freq or with sql you can get the number of patients that answers question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To know who reported I guess that you can transpose this dataset using as column the visits and transposing the &lt;SPAN style="font-size: 13.3333330154419px;"&gt;pfsy6mo&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=merged_visit2 out=trans_data;&lt;/P&gt;&lt;P&gt;by patid;&lt;/P&gt;&lt;P&gt;id visitnum;&lt;/P&gt;&lt;P&gt;var pfsy6mo;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 07:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Behaviors-Repeated-Measures/m-p/160559#M299647</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-02-11T07:20:56Z</dc:date>
    </item>
  </channel>
</rss>

