<?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: Counting the number of occurrence of a variable in an observation in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377539#M3055</link>
    <description>&lt;P&gt;this should work&lt;/P&gt;
&lt;PRE&gt;data want(drop=var:);
 set have;
 finalvar=sum(of var:);
 run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Jul 2017 19:20:46 GMT</pubDate>
    <dc:creator>kiranv_</dc:creator>
    <dc:date>2017-07-19T19:20:46Z</dc:date>
    <item>
      <title>Counting the number of occurrence of a variable in an observation</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377533#M3053</link>
      <description>&lt;P&gt;I'm on SAS University Edition - I have a data set with 792 rows and 29 columns; each column is a variable with value "0" or "1". &amp;nbsp;I would like to make a table with 792 rows and a single column, with the value of the single column being the number of "1"s in the corresponding observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;varA &amp;nbsp; &amp;nbsp; varB &amp;nbsp; &amp;nbsp; varC &amp;nbsp; &amp;nbsp; varD&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry if this is a basic question - I've new to SAS, and have looked around the forums and the internet without finding anything that has worked for me. &amp;nbsp;Much thanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 19:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377533#M3053</guid>
      <dc:creator>jsheu</dc:creator>
      <dc:date>2017-07-19T19:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of occurrence of a variable in an observation</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377535#M3054</link>
      <description>&lt;PRE&gt;data want (keep=sum);
  set have;
  array vars(*) varA--VarD;
  sum=sum(of vars(*));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 19:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377535#M3054</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-19T19:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of occurrence of a variable in an observation</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377539#M3055</link>
      <description>&lt;P&gt;this should work&lt;/P&gt;
&lt;PRE&gt;data want(drop=var:);
 set have;
 finalvar=sum(of var:);
 run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jul 2017 19:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377539#M3055</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-07-19T19:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of occurrence of a variable in an observation</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377576#M3058</link>
      <description>&lt;P&gt;I'm thinking that your real variable names don't all begin with "var".&amp;nbsp; If you want the sum of all numeric variables, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;new_column = sum(of _numeric_);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's not much point in putting this new column into a separate data set.&amp;nbsp; Once you do that, if you were to ever sort your data you couldn't match the new column back to the row that it came from.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 20:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/377576#M3058</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T20:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of occurrence of a variable in an observation</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/378564#M3091</link>
      <description>&lt;P&gt;Thanks, all! Looks like there a couple of ways to do this - I appreciate the help.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jul 2017 23:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Counting-the-number-of-occurrence-of-a-variable-in-an/m-p/378564#M3091</guid>
      <dc:creator>jsheu</dc:creator>
      <dc:date>2017-07-23T23:47:47Z</dc:date>
    </item>
  </channel>
</rss>

