<?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 Comparing Data in One Column to the Others in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575598#M162850</link>
    <description>&lt;P&gt;I am trying to compare the results from one column to others.&lt;/P&gt;&lt;P&gt;For example, I am looking at Q11 and want to know if, throughout the years, the answer for each study_id went from good to bad, bad to good, or stayed the same.&amp;nbsp; So I am trying to compare the earlier columns to the later ones. As you keep moving down the list, you will encounter other questions (Q12, Q13, Q26, Q31, etc.). Attached is a picture of some of the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31205i2B092281A5775BA8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2019 21:19:20 GMT</pubDate>
    <dc:creator>A_Halps</dc:creator>
    <dc:date>2019-07-22T21:19:20Z</dc:date>
    <item>
      <title>Comparing Data in One Column to the Others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575598#M162850</link>
      <description>&lt;P&gt;I am trying to compare the results from one column to others.&lt;/P&gt;&lt;P&gt;For example, I am looking at Q11 and want to know if, throughout the years, the answer for each study_id went from good to bad, bad to good, or stayed the same.&amp;nbsp; So I am trying to compare the earlier columns to the later ones. As you keep moving down the list, you will encounter other questions (Q12, Q13, Q26, Q31, etc.). Attached is a picture of some of the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31205i2B092281A5775BA8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 21:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575598#M162850</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2019-07-22T21:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Data in One Column to the Others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575607#M162857</link>
      <description>And then what? What do you want as output from this data? Are there multiple lines per StudyID or are you comparing answers between years for each question?&lt;BR /&gt;&lt;BR /&gt;Please don't post data as pictures, we can't do much with them. A text data set is much easier to work with.</description>
      <pubDate>Mon, 22 Jul 2019 21:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575607#M162857</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-22T21:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Data in One Column to the Others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575617#M162866</link>
      <description>&lt;P&gt;Do you more than 2 values for any of the ans2010 to 2019?&lt;/P&gt;
&lt;P&gt;What if you have a sequence like "good", "bad", "good"? what is the result?&lt;/P&gt;
&lt;P&gt;Or "good" "good" "bad" "bad" "bad" "bad" "good"?&lt;/P&gt;
&lt;P&gt;Or what if only one of the ans2010 to ans2019 has any value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have apparently 10 possible answers with LOTS of possible combinations: 3**10 actually (good, bad or missing for each). So your desired result really kind of depends on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sneaking suspicion that this data would benefit from coding "good" to a numeric 1 and "bad" to a zero, which would require new variables. At least&lt;/P&gt;
&lt;P&gt;r=&amp;nbsp;range(of num_ans:);&lt;/P&gt;
&lt;P&gt;g= sum(of num_ans:);&lt;/P&gt;
&lt;P&gt;b= n(of num_ans:) - g;&lt;/P&gt;
&lt;P&gt;m = mean(of num_ans:);&lt;/P&gt;
&lt;P&gt;if the numeric coded variables were named Num_ans_2010 to Num_ans_2019:&lt;/P&gt;
&lt;P&gt;if r=0 then all are the same.&lt;/P&gt;
&lt;P&gt;g&amp;nbsp;= the number of "good";&lt;/P&gt;
&lt;P&gt;b = the number of "bad";&lt;/P&gt;
&lt;P&gt;m= percentage of "good" among the answers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for&amp;nbsp;each row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 23:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575617#M162866</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-22T23:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Data in One Column to the Others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575694#M162903</link>
      <description>&lt;P&gt;Transpose, then analyze:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
  data=have
  out=trans (
    rename=(_name_=period col1=answer)
    where=(answer ne ' ')
  )
;
by study_id new_q;
var ans:;
run;

data want;
set trans;
by study_id new_q;
prev_ans = lag(answer);
length result $20;
if not first.new_q
then do;
  if prev_ans = answer then result = 'same';
  else if prev_ans = 'bad' then result = 'bad to good';
  else result = 'good to bad';
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 08:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-Data-in-One-Column-to-the-Others/m-p/575694#M162903</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-23T08:48:06Z</dc:date>
    </item>
  </channel>
</rss>

