<?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 computing multiple occurrences in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251704#M47604</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get a total of all roads (digit_road1 to digit_road4); When I used the sum &amp;nbsp;statement such as &amp;nbsp;total_digit=sum(of digit_road1-digit_road4) &amp;nbsp;I got the number of states 8&amp;nbsp;instead of 28 , which represents the number of occurence of roads.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Thanks&lt;/P&gt;&lt;P&gt;See code below&lt;/P&gt;&lt;P&gt;data traffic;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input state$ digit_road1 digit_road1 digit_road2 digit_road3 digit_road4 ;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AL &amp;nbsp; 101 103 &amp;nbsp; &amp;nbsp;. &amp;nbsp; 345&amp;nbsp;&lt;/P&gt;&lt;P&gt;AK &amp;nbsp; 205&amp;nbsp;590 500 700&lt;/P&gt;&lt;P&gt;AZ &amp;nbsp; &amp;nbsp;&amp;nbsp;.&amp;nbsp;100 390 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;IN &amp;nbsp; 890&amp;nbsp;623 . &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 678&lt;/P&gt;&lt;P&gt;MD 755&amp;nbsp;400 222 678&lt;/P&gt;&lt;P&gt;IL &amp;nbsp; 100&amp;nbsp;225 678 333&lt;/P&gt;&lt;P&gt;CA 800&amp;nbsp;455 900 567&lt;/P&gt;&lt;P&gt;TX 120 201 862 108;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2016 02:55:06 GMT</pubDate>
    <dc:creator>archibald</dc:creator>
    <dc:date>2016-02-23T02:55:06Z</dc:date>
    <item>
      <title>computing multiple occurrences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251704#M47604</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get a total of all roads (digit_road1 to digit_road4); When I used the sum &amp;nbsp;statement such as &amp;nbsp;total_digit=sum(of digit_road1-digit_road4) &amp;nbsp;I got the number of states 8&amp;nbsp;instead of 28 , which represents the number of occurence of roads.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Thanks&lt;/P&gt;&lt;P&gt;See code below&lt;/P&gt;&lt;P&gt;data traffic;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input state$ digit_road1 digit_road1 digit_road2 digit_road3 digit_road4 ;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AL &amp;nbsp; 101 103 &amp;nbsp; &amp;nbsp;. &amp;nbsp; 345&amp;nbsp;&lt;/P&gt;&lt;P&gt;AK &amp;nbsp; 205&amp;nbsp;590 500 700&lt;/P&gt;&lt;P&gt;AZ &amp;nbsp; &amp;nbsp;&amp;nbsp;.&amp;nbsp;100 390 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;IN &amp;nbsp; 890&amp;nbsp;623 . &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 678&lt;/P&gt;&lt;P&gt;MD 755&amp;nbsp;400 222 678&lt;/P&gt;&lt;P&gt;IL &amp;nbsp; 100&amp;nbsp;225 678 333&lt;/P&gt;&lt;P&gt;CA 800&amp;nbsp;455 900 567&lt;/P&gt;&lt;P&gt;TX 120 201 862 108;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 02:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251704#M47604</guid>
      <dc:creator>archibald</dc:creator>
      <dc:date>2016-02-23T02:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: computing multiple occurrences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251708#M47606</link>
      <description>&lt;P&gt;Where is 8 and 28 coming from based on your sample data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on your version of SAS you may need to reference the variable list as var1--var2 or var: to use all variables that start with the prefix "var".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't think that would happen with the OF keyword though. In older versions of SAS you could be taking the sum of road1-road4 which is really just the substraction of the two variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would you like your output to look like?&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>Tue, 23 Feb 2016 03:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251708#M47606</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-23T03:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: computing multiple occurrences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251713#M47608</link>
      <description>&lt;P&gt;Use the N function (count non missing arguments) and sum statements (retained and initialized at 0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data traffic;
  infile datalines;
  input state$ digit_road1 digit_road2 digit_road3 digit_road4 ;
datalines;
AL   101 103    .   345 
AK   205 590 500 700
AZ     . 100 390      .
IN   890 623 .       678
MD 755 400 222 678
IL   100 225 678 333
CA 800 455 900 567
TX 120 201 862 108
;

data roads;
set traffic end=done;
roads + n(of digit_road1-digit_road4);
states + 1;
if done then output;
keep roads states;
run;

proc print data=roads noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Feb 2016 03:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251713#M47608</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-02-23T03:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: computing multiple occurrences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251933#M47695</link>
      <description>8 is the number of cases, that is the number of observations (states).&lt;BR /&gt;I wat the output to be the total of all the digit_road variables.&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Feb 2016 01:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-multiple-occurrences/m-p/251933#M47695</guid>
      <dc:creator>archibald</dc:creator>
      <dc:date>2016-02-24T01:12:44Z</dc:date>
    </item>
  </channel>
</rss>

