<?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: SAS newbie trying to tally in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665897#M199169</link>
    <description>My last SQL code is what you want then.</description>
    <pubDate>Mon, 29 Jun 2020 19:15:12 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-29T19:15:12Z</dc:date>
    <item>
      <title>SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665856#M199144</link>
      <description>&lt;P&gt;I'm just beginning to learn SAS and this is what I'm trying to do and would appreciate any help I can find.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my data, each member has an observation&amp;nbsp;I would like to tally the number of times VAR1 occurs when it matches another observation with the same VAR1 and also VAR2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for the following data, there would be 2 matches ob1/ob2 and ob4/ob5/ob6, for a count of 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ob1 VAR1=1 VAR2=1&lt;/P&gt;&lt;P&gt;ob2 VAR1=1 VAR2=1&lt;/P&gt;&lt;P&gt;ob3 VAR1=1 VAR2=2&lt;/P&gt;&lt;P&gt;ob4 VAR1=2 VAR2=2&lt;/P&gt;&lt;P&gt;ob5 VAR1=2 VAR2=2&lt;/P&gt;&lt;P&gt;ob6 VAR1=2 VAR2=2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665856#M199144</guid>
      <dc:creator>briannascott</dc:creator>
      <dc:date>2020-06-29T17:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665857#M199145</link>
      <description>&lt;P&gt;You don't show what you expect for output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might try&lt;/P&gt;
&lt;PRE&gt;Proc freq data=have;&lt;BR /&gt;   where var1 = var2;
   tables var1*var2 /list;
run;&lt;/PRE&gt;
&lt;P&gt;which will count all of the combinations of var1 and var2. If you have missing values and want to include those add the Missing option.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665857#M199145</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T17:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665860#M199147</link>
      <description>&lt;P&gt;thanks but that doesn't do it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to count (tally?) how many times VAR1 matches another observation, so where VAR1=VAR1&lt;/P&gt;&lt;P&gt;and also meets the other condition - where both observations have the same VAR2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the output would just be a count of 2 in the example.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665860#M199147</guid>
      <dc:creator>briannascott</dc:creator>
      <dc:date>2020-06-29T17:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665862#M199149</link>
      <description>&lt;P&gt;Provide an actual example of how the output is supposed to look.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665862#M199149</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T17:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665863#M199150</link>
      <description>&lt;P&gt;PROC FREQ would output 2 records, that's your answer, 2.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665863#M199150</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-29T17:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665869#M199154</link>
      <description>You need to expand your example then to incorporate that. &lt;BR /&gt;&lt;BR /&gt;I would suggest showing a table of what you have and for that data set as input, exactly what you expect as output. Your current example is unfortunately too simple as there are multiple ways to easily get your stated answer of 2.</description>
      <pubDate>Mon, 29 Jun 2020 17:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665869#M199154</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-29T17:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665870#M199155</link>
      <description>&lt;P&gt;It would be a count, it wouldn't be a frequency of observations.&lt;/P&gt;&lt;P&gt;A count of how many times there are matching VAR1s that also have the same VAR2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm sorry if I'm not explaining it clearly enough.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665870#M199155</guid>
      <dc:creator>briannascott</dc:creator>
      <dc:date>2020-06-29T17:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665872#M199157</link>
      <description>&lt;P&gt;So you mean&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(*)
from have
where var1 = var2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665872#M199157</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-29T17:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665874#M199158</link>
      <description>More likely this:&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select count(distinct var1) as Count&lt;BR /&gt;from have&lt;BR /&gt;where var1 = var2;&lt;BR /&gt;quit;</description>
      <pubDate>Mon, 29 Jun 2020 17:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665874#M199158</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-29T17:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665875#M199159</link>
      <description>&lt;P&gt;where var1=var1 of a different observation.&lt;/P&gt;&lt;P&gt;that's what i'm trying to count in the data.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665875#M199159</guid>
      <dc:creator>briannascott</dc:creator>
      <dc:date>2020-06-29T18:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665880#M199161</link>
      <description>That's not what's shown in the sample data. Please post a better example of what you have and what you want.</description>
      <pubDate>Mon, 29 Jun 2020 18:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665880#M199161</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-29T18:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665884#M199164</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335820"&gt;@briannascott&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;where var1=var1 of a different observation.&lt;/P&gt;
&lt;P&gt;that's what i'm trying to count in the data.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(var1)
from have
group by var1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
tables var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665884#M199164</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-29T18:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665885#M199165</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335820"&gt;@briannascott&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It would be a count, it wouldn't be a frequency of observations.&lt;/P&gt;
&lt;P&gt;A count of how many times there are matching VAR1s that also have the same VAR2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i'm sorry if I'm not explaining it clearly enough.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Adding to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;'s earlier answer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc freq data=have;
   where var1 = var2;
   tables var1*var2 /noprint out=counts;
run;
proc means data=counts n;
    var count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665885#M199165</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-29T18:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665886#M199166</link>
      <description>&lt;P&gt;&lt;FONT color="#008000"&gt;obs1 VAR1=A VAR2=1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;obs2 VAR1=A VAR2=1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;obs3 VAR1=B VAR2=2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;obs4 VAR1=B VAR2=2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;obs5 VAR1=B VAR2=2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;obs6 VAR1=C VAR2=1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;obs7 VAR1=C VAR2=1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;obs8 VAR1=C VAR2=2&lt;/P&gt;&lt;P&gt;obs9 VAR1=D VAR2=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output would simply be a count of "3"&lt;/P&gt;&lt;P&gt;Count 1 - obs1 and obs2 match on VAR1 as both have a value of A and also match on VAR2 with value of 1&lt;/P&gt;&lt;P&gt;Count 2 - obs3, obs4, obs5 match on VAR1=B, match on VAR2=2&lt;/P&gt;&lt;P&gt;Count 3 - obs6 and obs7 match on VAR1=C, VAR2=1&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't care about obs8 since it didn't match VAR2 with obs6&lt;/P&gt;&lt;P&gt;I don't care about obs9 since it doens't match VAR1 with any&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665886#M199166</guid>
      <dc:creator>briannascott</dc:creator>
      <dc:date>2020-06-29T18:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665888#M199167</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select var1, var2, count(*) as count
from have
group by var1, var2
having count &amp;gt; 1;
quit;
%put &amp;amp;sqlobs.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665888#M199167</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-29T18:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS newbie trying to tally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665897#M199169</link>
      <description>My last SQL code is what you want then.</description>
      <pubDate>Mon, 29 Jun 2020 19:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-newbie-trying-to-tally/m-p/665897#M199169</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-29T19:15:12Z</dc:date>
    </item>
  </channel>
</rss>

