<?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: Help with Frequencies in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684788#M24243</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281255"&gt;@marleeakerson&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281255"&gt;@marleeakerson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to run a frequency to see the frequency of people (IDs) who went from positive to negative, how many went from negative to positive, and all the other combinations (pos to neg and then back to pos, etc.).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you want to count an ID with, e.g., &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt; followed by &lt;FONT face="courier new,courier"&gt;Neg&lt;/FONT&gt; in the same category as an ID with four times &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt; followed by three times &lt;FONT face="courier new,courier"&gt;Neg&lt;/FONT&gt; (because both went from &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt; to &lt;FONT face="courier new,courier"&gt;Neg&lt;/FONT&gt;), but not in the same category as an ID that after this change switched back to &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length seq $100;
do until(last.id);
  set have;
  by id result notsorted;
  if first.result then seq=catx(',', seq, result);
end;
drop result;
run;

proc freq data=want;
tables seq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that your dataset (HAVE) is sorted by ID. (Add a PROC SORT step if this is not the case.) Adapt the length of character variable SEQ (100) as needed to accommodate the relevant sequences "&lt;FONT face="courier new,courier"&gt;Pos,Neg,Pos,&lt;/FONT&gt;..." etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Sep 2020 20:18:15 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2020-09-17T20:18:15Z</dc:date>
    <item>
      <title>Help with Frequencies</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684733#M24236</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to run a frequency but need some help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this sample data set:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Result&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pos&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Neg&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pos&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Neg&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pos&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pos&lt;/P&gt;
&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Neg&lt;/P&gt;
&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pos&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to run a frequency to see the frequency of people (IDs) who went from positive to negative, how many went from negative to positive, and all the other combinations (pos to neg and then back to pos, etc.).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me out with this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 18:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684733#M24236</guid>
      <dc:creator>marleeakerson</dc:creator>
      <dc:date>2020-09-17T18:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Frequencies</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684754#M24237</link>
      <description>&lt;P&gt;Prepare counts for changes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data prefreq;
set have;
by id;
_result = lag(result);
if first.id
then do;
  count_neg_to_pos = 0;
  count_pos_to_neg = 0;
end;
else do;
  if _result = "Neg" and result = "Pos" then count_neg_to_pos + 1;
  if _result = "Pos" and result = "Neg" then count_pos_to_neg + 1;
end;
if last.id;
drop result_result;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684754#M24237</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-17T19:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Frequencies</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684788#M24243</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281255"&gt;@marleeakerson&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281255"&gt;@marleeakerson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to run a frequency to see the frequency of people (IDs) who went from positive to negative, how many went from negative to positive, and all the other combinations (pos to neg and then back to pos, etc.).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you want to count an ID with, e.g., &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt; followed by &lt;FONT face="courier new,courier"&gt;Neg&lt;/FONT&gt; in the same category as an ID with four times &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt; followed by three times &lt;FONT face="courier new,courier"&gt;Neg&lt;/FONT&gt; (because both went from &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt; to &lt;FONT face="courier new,courier"&gt;Neg&lt;/FONT&gt;), but not in the same category as an ID that after this change switched back to &lt;FONT face="courier new,courier"&gt;Pos&lt;/FONT&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length seq $100;
do until(last.id);
  set have;
  by id result notsorted;
  if first.result then seq=catx(',', seq, result);
end;
drop result;
run;

proc freq data=want;
tables seq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that your dataset (HAVE) is sorted by ID. (Add a PROC SORT step if this is not the case.) Adapt the length of character variable SEQ (100) as needed to accommodate the relevant sequences "&lt;FONT face="courier new,courier"&gt;Pos,Neg,Pos,&lt;/FONT&gt;..." etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 20:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-Frequencies/m-p/684788#M24243</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-09-17T20:18:15Z</dc:date>
    </item>
  </channel>
</rss>

