<?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 Trying to reverse code without including missing, IDK, or prefer not to answer in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924728#M363980</link>
    <description>&lt;P&gt;I am trying to reverse code some variables in a 4-point likert scale. I do not want to include the missing variables, or those that said "I don't know" (98) or "Prefer not to answer" (99).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code is set up like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; DISRUPT_likert1;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;set&lt;/SPAN&gt; DISRUPT_likert;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;IF&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;(Q15_1 ne &lt;SPAN class=""&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;) OR (Q15_1 ne &lt;SPAN class=""&gt;&lt;STRONG&gt;99&lt;/STRONG&gt;&lt;/SPAN&gt;) OR (Q15_1 ne &lt;SPAN class=""&gt;&lt;STRONG&gt;98&lt;/STRONG&gt;&lt;/SPAN&gt;) &lt;SPAN class=""&gt;THEN&lt;/SPAN&gt; Q15_1RC = &lt;SPAN class=""&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;-Q15_1;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;It is still including 99 and 98. Can someone help me find why?&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 16:20:38 GMT</pubDate>
    <dc:creator>racekarrz2</dc:creator>
    <dc:date>2024-04-17T16:20:38Z</dc:date>
    <item>
      <title>Trying to reverse code without including missing, IDK, or prefer not to answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924728#M363980</link>
      <description>&lt;P&gt;I am trying to reverse code some variables in a 4-point likert scale. I do not want to include the missing variables, or those that said "I don't know" (98) or "Prefer not to answer" (99).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code is set up like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; DISRUPT_likert1;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;set&lt;/SPAN&gt; DISRUPT_likert;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;IF&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;(Q15_1 ne &lt;SPAN class=""&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;) OR (Q15_1 ne &lt;SPAN class=""&gt;&lt;STRONG&gt;99&lt;/STRONG&gt;&lt;/SPAN&gt;) OR (Q15_1 ne &lt;SPAN class=""&gt;&lt;STRONG&gt;98&lt;/STRONG&gt;&lt;/SPAN&gt;) &lt;SPAN class=""&gt;THEN&lt;/SPAN&gt; Q15_1RC = &lt;SPAN class=""&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;-Q15_1;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;It is still including 99 and 98. Can someone help me find why?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 16:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924728#M363980</guid>
      <dc:creator>racekarrz2</dc:creator>
      <dc:date>2024-04-17T16:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to reverse code without including missing, IDK, or prefer not to answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924731#M363983</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;IF&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;Q15_1 not in ( &lt;SPAN class=""&gt;&lt;STRONG&gt;.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;STRONG&gt;99&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;STRONG&gt;98&lt;/STRONG&gt;&lt;/SPAN&gt;) &lt;SPAN class=""&gt;THEN&lt;/SPAN&gt; Q15_1RC = &lt;SPAN class=""&gt;&lt;STRONG&gt;5 &lt;/STRONG&gt;&lt;/SPAN&gt;- Q15_1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IN tests for values to be any of those in the parentheses. The list can be space or comma delimited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you combine comparisons with an OR then the result is 'True' if any of the pieces are.&lt;/P&gt;
&lt;P&gt;So when the value is 98 then Q15_1 ne . is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might consider naming the variable RC_Q15_1. The way SAS works you can easily make list of variables that have a common prefix but not a suffix. The may come a time when you want to do something with all of the RC variables (an array perhaps or get a Sum/Mean/Range or other calculations or Keep or Drop). Using RC_:&amp;nbsp; would build a list of all variables whose names start with RC_.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 16:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924731#M363983</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-17T16:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to reverse code without including missing, IDK, or prefer not to answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924732#M363984</link>
      <description>Great this worked, thank you! I also took your advice and changed all the reverse coded variables to start with "RC"</description>
      <pubDate>Wed, 17 Apr 2024 16:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924732#M363984</guid>
      <dc:creator>racekarrz2</dc:creator>
      <dc:date>2024-04-17T16:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to reverse code without including missing, IDK, or prefer not to answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924733#M363985</link>
      <description>&lt;P&gt;If you have multiple variables that need the same calculations then arrays are handy. For example making up some variable names to use. If you haven't used arrays yet they are a shorthand way of doing the same thing to multiple variables (among a few other bits).&lt;/P&gt;
&lt;P&gt;The array statement defines the array with the first thing the name (can't be an existing variable) and the list of variables that will be referenced. Note that placing the two array definitions next to each other you can easily check that the number of elements in the Q (question) and RC (Recode) lists are the same. You might even figure out how to use editor search and replace on a copy of the Array Q statement to do most of the renaming in the Array RC. The Dim function returns a count of defined elements. You use arrayname(index number) to reference the elements. So q[i] is Q15_1. You can use () or [] to enclose the index value. I tend to us [] so it is easier to tell array reference from all the other () that can appear in a complex expression.&lt;/P&gt;
&lt;PRE&gt;   array q (*)    Q15_1    Q17_2    Q20_1;
   array rc(*) RC_Q15_1 RC_Q17_2 RC_Q20_1;
   do i=1 to dim(q);
      IF  q[i] not in ( .  99 98) THEN rc[i] = 5 - q[i];
   end;
&lt;/PRE&gt;
&lt;P&gt;Note that the index must be an integer and can be an expression which can be handy as well.&lt;/P&gt;
&lt;P&gt;There are functions WHICHN and WHICHC that can be used to search for a value from a list. One use of arrays is to be short had for that list:&amp;nbsp; WHICHN(3, of q[*]) will return the&amp;nbsp; element number of the first variable having the value 3. WHICHC is for character values.&lt;/P&gt;
&lt;P&gt;The functions SUM, MIN, MAX, MEAN, Call Missing and most of the functions that accept a list of variables will also use the "of array[*]" as a list of variables for the function.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 17:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-reverse-code-without-including-missing-IDK-or-prefer/m-p/924733#M363985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-17T17:15:55Z</dc:date>
    </item>
  </channel>
</rss>

