<?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 Recoding Variables and Arithmetic in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21798#M4688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm ... not sure where to find this online.&amp;nbsp; But what I posted might just be enough.&amp;nbsp; Experiment with it a bit and it will probably become clear.&amp;nbsp; Try running some PROC FREQs with the MISSING option on the TABLES statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Mar 2012 16:53:24 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-03-05T16:53:24Z</dc:date>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21791#M4681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;Hi. I am very new to SAS.I’m working on a project which involves recoding a large amount of evaluation survey questions, scoring them and then aggregating the scores. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;In the dataset below thereare the values of 1,2,3,4. “4” means the question was not applicable in those cases. So, for var1 there are 9 cases applicable, for var2 there are 7 and var3all 10 cases are applicable.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines dlm=',' dsd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input Record $ var1 var2 var3;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;"Record1", 1,2,2&lt;/P&gt;&lt;P&gt;"Record2 ",1,2,2&lt;/P&gt;&lt;P&gt;"Record3 ",1,2,2&lt;/P&gt;&lt;P&gt;"Record4 ",2,3,3&lt;/P&gt;&lt;P&gt;"Record5 ",1,1,1&lt;/P&gt;&lt;P&gt;" Record6",3,3,3&lt;/P&gt;&lt;P&gt;" Record7",1,3,3&lt;/P&gt;&lt;P&gt;" Record8",3,4,1&lt;/P&gt;&lt;P&gt;" Record9",1,4,1&lt;/P&gt;&lt;P&gt;" Record10",4,4,3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;Questions are weighted differently –there are three categories 1 point, 2 point, 3 point questions. I recode the questions so the responses are reflective of their point value.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;Initial codeing:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;1=YES&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;2=NO&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;3=Incomplete&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;4=N/A &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Recode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new; &lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;if var1=1 then Var1New= 1; else;&lt;/P&gt;&lt;P&gt;if var1=2 then Var1New= 0; else;&lt;/P&gt;&lt;P&gt;if var1=3 then Var1New=.5; else;&lt;/P&gt;&lt;P&gt;if var1=4 then Var1New=.;else &lt;/P&gt;&lt;P&gt;if var2=1 then Var2New= 2; else;&lt;/P&gt;&lt;P&gt;if var2=2 then Var2New= 0; else;&lt;/P&gt;&lt;P&gt;if var2=3 then Var2New=1; else;&lt;/P&gt;&lt;P&gt;if var2=4 then Var2New=.;else &lt;/P&gt;&lt;P&gt;if var3=1 then Var3new=3; else;&lt;/P&gt;&lt;P&gt;if var3=2 then Var3new=0; else;&lt;/P&gt;&lt;P&gt;if var3=3 then Var3new=1.5; else;&lt;/P&gt;&lt;P&gt;if var3=4 then Var3new=.; else;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this is where my SAS knowledge gets fuzzy (again, i am a SAS beginner). I need to award each Var a score and then &lt;SPAN style="font-family: Arial;"&gt;aggregate &lt;/SPAN&gt;them for a final score. The math should look something like this table: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="margin-left: 4.65pt; width: 553px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border-image: initial; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt; border-width: 1pt; border-color: windowtext; border-style: solid;" valign="bottom" width="49"&gt; &lt;P align="center"&gt;&lt;STRONG style="font-size: 10pt; font-family: Arial;"&gt; &lt;/STRONG&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: 1pt; border-right-width: initial; border-bottom-width: 1pt; border-left-width: initial; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-top-color: windowtext; border-right-color: initial; border-bottom-color: windowtext; border-left-color: initial; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Question Point Value &lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: 1pt; border-right-width: initial; border-bottom-width: 1pt; border-left-width: initial; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-top-color: windowtext; border-right-color: initial; border-bottom-color: windowtext; border-left-color: initial; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Records Applicable&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: 1pt; border-right-width: initial; border-bottom-width: 1pt; border-left-width: initial; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-top-color: windowtext; border-right-color: initial; border-bottom-color: windowtext; border-left-color: initial; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="120"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Highest possible Score&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="108"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Points Awarded &lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="84"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;SCORE&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="49"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;VAR1&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;9&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="120"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;1X9 records=9&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="108"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;7&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="84"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;77.7%&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="49"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;VAR2&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;7&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="120"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;2X7 records=14&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="108"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;5&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="84"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;35.7%&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="49"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;VAR3&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="96"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="120"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;3X10 records=30&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="108"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;16.5&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top-width: initial; border-top-color: initial; border-bottom-width: 1pt; border-bottom-color: windowtext; border-left-width: initial; border-left-color: initial; border-right-width: 1pt; border-right-color: windowtext; border-top-style: none; border-right-style: solid; border-bottom-style: solid; border-left-style: none; padding-top: 0px; padding-bottom: 0px; padding-left: 5.4pt; padding-right: 5.4pt;" valign="bottom" width="84"&gt; &lt;P align="center"&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;55%&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then total score is 28.5/ 53 = &lt;STRONG&gt;TOTAL SCORE&amp;nbsp; 53.7%&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my questions are: how do you write code to do the equations and is there a way that you can recode and perform the calculations on a large group of variables at once? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thank you in advance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 20:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21791#M4681</guid>
      <dc:creator>Rick79</dc:creator>
      <dc:date>2012-03-04T20:01:26Z</dc:date>
    </item>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21792#M4682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One slight change to your coding.&amp;nbsp; You wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;data new;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;set old;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var1=1 then Var1New= 1; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var1=2 then Var1New= 0; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var1=3 then Var1New=.5; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var1=4 then Var1New=.;else&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var2=1 then Var2New= 2; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var2=2 then Var2New= 0; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var2=3 then Var2New=1; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var2=4 then Var2New=.;else&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var3=1 then Var3new=3; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var3=2 then Var3new=0; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var3=3 then Var3new=1.5; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if var3=4 then Var3new=.; else;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would work is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;data new;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp; set old;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp; if var1=1 then Var1New= 1;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var1=2 then Var1New= 0;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var1=3 then Var1New=.5; &lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var1=4 then Var1New=.;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp; if var2=1 then Var2New= 2;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var2=2 then Var2New= 0;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var2=3 then Var2New=1;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var2=4 then Var2New=.;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp; if var3=1 then Var3new=3;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var3=2 then Var3new=0;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var3=3 then Var3new=1.5;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else if var3=4 then Var3new=.;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are the ten records your entire dataset or does every subject have a set of 10 records?&amp;nbsp; And, if it is the latter, will there always be 10 records per subject and will they always be ordered 1 thru 10?&amp;nbsp; And, if there are a number of subjects is there, or should there be, an ID field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 20:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21792#M4682</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-04T20:22:17Z</dc:date>
    </item>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21793#M4683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! In this case yes, the 10 records are the entire dataset. You could say the record variable is the ID variable for each case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 20:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21793#M4683</guid>
      <dc:creator>Rick79</dc:creator>
      <dc:date>2012-03-04T20:46:26Z</dc:date>
    </item>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21794#M4684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think there is a typo in the var3 score, it should be 15, not 16.5. &lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; infile datalines dlm=',' dsd;&lt;BR /&gt;&amp;nbsp; input Record $ var1 var2 var3;&lt;BR /&gt;datalines;&lt;BR /&gt;"Record1", 1,2,2&lt;BR /&gt;"Record2 ",1,2,2&lt;BR /&gt;"Record3 ",1,2,2&lt;BR /&gt;"Record4 ",2,3,3&lt;BR /&gt;"Record5 ",1,1,1&lt;BR /&gt;"Record6",3,3,3&lt;BR /&gt;"Record7",1,3,3&lt;BR /&gt;"Record8",3,4,1&lt;BR /&gt;"Record9",1,4,1&lt;BR /&gt;"Record10",4,4,3&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data points;&lt;BR /&gt;input question $ response score;&lt;BR /&gt;datalines;&lt;BR /&gt;var1 1 1&lt;BR /&gt;var1 2 0&lt;BR /&gt;var1 3 0.5&lt;BR /&gt;var1 4 .&lt;BR /&gt;var2 1 2&lt;BR /&gt;var2 2 0&lt;BR /&gt;var2 3 1&lt;BR /&gt;var2 4 .&lt;BR /&gt;var3 1 3&lt;BR /&gt;var3 2 0&lt;BR /&gt;var3 3 1.5&lt;BR /&gt;var3 4 .&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have out=temp name=question;&lt;BR /&gt;var var1-var3;&lt;BR /&gt;by record notsorted;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table questionScores as&lt;BR /&gt;select T.question label="Question", &lt;BR /&gt;count(score) as applicable, M.scoreMax*calculated applicable as highestPossible,&lt;BR /&gt;sum(score) as pointsAwarded, calculated pointsAwarded/calculated highestPossible as questionScore&lt;BR /&gt;from temp as T, points as P, (select question, max(score) as scoreMax from points group by question) as M&lt;BR /&gt;where T.question=P.question and T.COL1=P.response and T.question=M.question&lt;BR /&gt;group by T.question, M.scoreMax;&lt;BR /&gt;create table totalScore as&lt;BR /&gt;select sum(pointsAwarded) as totalAwarded, sum(highestPossible) as totalPossible,&lt;BR /&gt;calculated totalAwarded / calculated totalPossible as score&lt;BR /&gt;from questionScores;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;BR /&gt;title "Question scores";&lt;BR /&gt;select * from questionScores;&lt;BR /&gt;title "Total score";&lt;BR /&gt;select * from totalScore;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 21:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21794#M4684</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-04T21:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21795#M4685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more small point to consider ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible that your variables contain missing values BEFORE you change their values.&amp;nbsp; If you change "4" to missing, you won't be able to distinguish between values that were missing originally and values that were "4" originally.&amp;nbsp; SAS provides a neat way around that.&amp;nbsp; It allows special missing values, for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else if var1=4 then var1new=.A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are 27 special missing values (.A through .Z, and ._).&amp;nbsp; They would all be thrown out of the calculations by PROC MEANS (or whatever you use for subsequent processing), but could be distinguished one from another.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you refer to them in your code, the sorted order is ._ then . then .A through .Z, so you might have to change the way you examine for missing values.&amp;nbsp; Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1new = . then ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you would need to code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1new &amp;lt;= .Z then ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1new &amp;gt; . then ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you would need to code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1new &amp;gt; .Z then ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 14:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21795#M4685</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-03-05T14:14:06Z</dc:date>
    </item>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21796#M4686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much! This works great. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 16:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21796#M4686</guid>
      <dc:creator>Rick79</dc:creator>
      <dc:date>2012-03-05T16:34:32Z</dc:date>
    </item>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21797#M4687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You made a very good point regarding missing values. Right now, my office has a very poor way of handling them in or surveys. Do you have/or know of and very eay to understand literature regarding SAS &lt;SPAN style="background-color: #ffffff;"&gt;special missing values I have been looking online and I can't find a lot. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Thanks! &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 16:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21797#M4687</guid>
      <dc:creator>Rick79</dc:creator>
      <dc:date>2012-03-05T16:37:14Z</dc:date>
    </item>
    <item>
      <title>Recoding Variables and Arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21798#M4688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm ... not sure where to find this online.&amp;nbsp; But what I posted might just be enough.&amp;nbsp; Experiment with it a bit and it will probably become clear.&amp;nbsp; Try running some PROC FREQs with the MISSING option on the TABLES statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 16:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Recoding-Variables-and-Arithmetic/m-p/21798#M4688</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-03-05T16:53:24Z</dc:date>
    </item>
  </channel>
</rss>

