<?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 How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804267#M316703</link>
    <description>&lt;P&gt;I have 11 variables with the following categories:&lt;/P&gt;&lt;P&gt;0 = absent&lt;/P&gt;&lt;P&gt;1 = active&lt;/P&gt;&lt;P&gt;2 = inactive&lt;/P&gt;&lt;P&gt;8 = uk/dk&lt;/P&gt;&lt;P&gt;9 = missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new variable for the total score for number of "1's".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I want to know how many study participants have 2 or more #1's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a new user and don't know if I need to do if then statements, sum statement etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 26 Mar 2022 14:54:47 GMT</pubDate>
    <dc:creator>gtucke1</dc:creator>
    <dc:date>2022-03-26T14:54:47Z</dc:date>
    <item>
      <title>How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804267#M316703</link>
      <description>&lt;P&gt;I have 11 variables with the following categories:&lt;/P&gt;&lt;P&gt;0 = absent&lt;/P&gt;&lt;P&gt;1 = active&lt;/P&gt;&lt;P&gt;2 = inactive&lt;/P&gt;&lt;P&gt;8 = uk/dk&lt;/P&gt;&lt;P&gt;9 = missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new variable for the total score for number of "1's".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I want to know how many study participants have 2 or more #1's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a new user and don't know if I need to do if then statements, sum statement etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 14:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804267#M316703</guid>
      <dc:creator>gtucke1</dc:creator>
      <dc:date>2022-03-26T14:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804270#M316704</link>
      <description>&lt;P&gt;You can use a data step with an array:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array vars {*} /* put your 11 variables here */;
count = 0;
do i = 1 to dim(vars);
  count + (vars{i} = 1);
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would prefer a long data structure, which allows this simple code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    id,
    sum(var = 1) as count
  from have
  group by id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have (where=(var = 1)) nway;
class id;
var var;
output out=want sum()=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 15:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804270#M316704</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-26T15:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804271#M316705</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input particip $ catvar1 $ catvar2 $ catvar3 $ catvar4  $ catvar5  $ 
       catvar6  $ catvar7 $ catvar8 $ catvar9 $ catvar10 $ catvar11 $;
datalines;
ABC 0 1 2 8 9 0 1 2 8 9 2
;
run;

data want(drop = i);
 set have;
 array catvar[11] $ catvar1 - catvar11;
 number_of_1s = 0;
 do i = 1 to dim(catvar);
  if catvar(i)='1' then number_of_1s = number_of_1s + 1;
 end;
run;

PROC FREQ data=want;
 tables number_of_1s ;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 15:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804271#M316705</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-26T15:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804289#M316716</link>
      <description>&lt;P&gt;Thank you for the help. I'm using a dataset, not data lines. Would I do something similar?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 19:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804289#M316716</guid>
      <dc:creator>gtucke1</dc:creator>
      <dc:date>2022-03-26T19:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804290#M316717</link>
      <description>&lt;P&gt;Thank you. I'll give these a try.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 19:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804290#M316717</guid>
      <dc:creator>gtucke1</dc:creator>
      <dc:date>2022-03-26T19:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804292#M316719</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/414915"&gt;@gtucke1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This simply means you already have your data set 'have'.&lt;/P&gt;
&lt;P&gt;In the 2nd data step (with the array processing), replace the data set named 'have' in the set statement by your own input data set.&lt;/P&gt;
&lt;P&gt;I assumed that these 11 variables are string-type (char). You need slight changes if your 11 variables are numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 20:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804292#M316719</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-26T20:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804377#M316754</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure how to input my information. In the examples you provided.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 11 variables are listed as dx_chf dx_copd dx_hiv etc. I want to add up all of the "active" which = 1 to come to a total of X active diagnoses. Then I want to determine how many participants have 2 or more active diagnoses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 14:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804377#M316754</guid>
      <dc:creator>gtucke1</dc:creator>
      <dc:date>2022-03-27T14:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804419#M316771</link>
      <description>&lt;P&gt;Here is way to do it quickly that takes advantage of the fact that all of the possible values are one digit long.&lt;/P&gt;
&lt;P&gt;Let's assume you have a dataset name HAVE and the variables are named VAR1 to VAR11.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  score = countc(cats(of var1-var11),'1');
  over2 = (score &amp;gt; 1);
run;
proc freq data=want;
  tables over2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The CATS() function will create a string by concatenating the values of the listed variables with leading/trailing spaces removed.&amp;nbsp; If the any of the variables are numeric they will be silently converted to strings first.&lt;/P&gt;
&lt;P&gt;The COUNTC() function counts how many times the characters in the second argument appear in the first argument.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So SCORE will have how many 1's there were in the eleven variables.&lt;/P&gt;
&lt;P&gt;SAS will convert a boolean expression like, score &amp;gt; 1, into 0 for false and 1 for true.&amp;nbsp; So OVER2 will be 1 when there were two or more 1's in the eleven varaibles.&lt;/P&gt;
&lt;P&gt;PROC FREQ will show you the counts of 1 and 0's in the OVER2 variable.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 17:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804419#M316771</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-27T17:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a total score out of questions with values of 0=absent 1=active 2=inactive etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804442#M316789</link>
      <description>&lt;P&gt;Thank you very much for the explanation. It worked!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 21:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-total-score-out-of-questions-with-values-of-0/m-p/804442#M316789</guid>
      <dc:creator>gtucke1</dc:creator>
      <dc:date>2022-03-27T21:29:12Z</dc:date>
    </item>
  </channel>
</rss>

