<?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: Proc Freq Double Counting Certain Outputs in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606612#M8353</link>
    <description>&lt;P&gt;Apologies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe this is where the error is. (Observations = 20)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LogOutput.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34189iA3DC3EBFF58EE8B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="LogOutput.PNG" alt="LogOutput.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2019 23:50:33 GMT</pubDate>
    <dc:creator>cassylovescats</dc:creator>
    <dc:date>2019-11-22T23:50:33Z</dc:date>
    <item>
      <title>Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606605#M8351</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname Example "~/my_courses/Homework/FinalHomework";&lt;/P&gt;&lt;P&gt;data Sugar;&lt;BR /&gt;length DistrictGroup $ 30;&lt;BR /&gt;infile '~/my_courses/Homework/FinalHomework/CaneData2.csv/' dsd firstobs=2;&lt;BR /&gt;input District $ DistrictGroup $ DistrictPosition $ SoilID SoilName $ Area Variety $ Ratoon $ Age HarvestMonth HarvestDuration&amp;nbsp;TonnHect Fibre&amp;nbsp;Sugar&amp;nbsp;Jul96&amp;nbsp;Aug96&amp;nbsp;Sep96&amp;nbsp;Oct96&amp;nbsp;Nov96&amp;nbsp;Dec96&amp;nbsp;Jan97&amp;nbsp;Feb97&amp;nbsp;Mar97&amp;nbsp;Apr97&amp;nbsp;May97&amp;nbsp;Jun97&amp;nbsp;Jul97&amp;nbsp;Aug97&amp;nbsp;Sep97&amp;nbsp;Oct97&amp;nbsp;Nov97&amp;nbsp;Dec97;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data SugarLong;&amp;nbsp;&lt;BR /&gt;set Sugar;&lt;BR /&gt;array mon{*} _numeric_;&lt;BR /&gt;do _n_=9 to dim(mon);&lt;BR /&gt;Month=vname(mon[_n_]);&lt;BR /&gt;Count=mon[_n_];&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;drop Month DistrictGroup SoilID SoilName Area Variety Ratoon Age HarvestMonth HarvestDuration&amp;nbsp;TonnHect Fibre&amp;nbsp;Sugar Jul96&amp;nbsp;Aug96&amp;nbsp;Sep96&amp;nbsp;Oct96&amp;nbsp;Nov96&amp;nbsp;Dec96&amp;nbsp;Jan97&amp;nbsp;Feb97&amp;nbsp;Mar97&amp;nbsp;Apr97&amp;nbsp;May97&amp;nbsp;&lt;BR /&gt;Jun97&amp;nbsp;Jul97&amp;nbsp;Aug97&amp;nbsp;Sep97&amp;nbsp;Oct97&amp;nbsp;Nov97&amp;nbsp;Dec97;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data SugarLongResult;&lt;BR /&gt;&amp;nbsp; set SugarLong;&lt;BR /&gt;&amp;nbsp; select;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (Count &amp;gt; 0) Result='Yes';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise Result='No';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Proc print data=SugarLongResult (obs=50);&lt;BR /&gt;var District DistrictPosition Result;&lt;BR /&gt;print;&lt;/P&gt;&lt;P&gt;proc sort data=SugarLongResult out=SugarLongResultDupe NODUPKEY;&lt;BR /&gt;&amp;nbsp; by District DistrictPosition Result;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=SugarLongResultDupe;&lt;BR /&gt;tables DistrictPosition* Result / out=SugarLongResultFinal;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=SugarLongResultFinal;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are only 15 District options but the output is currently adding up to 20. The problem seems to be with S, W, and C, it looks like it's including the count of No in both No and Yes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The correct numbers are below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;DistrictPosition&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Result&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Count&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;N&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Yes&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;N&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;No&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;E&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Yes&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;E&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;No&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;S&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Yes&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;S&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;No&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;W&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Yes&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;W&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;No&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;C&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Yes&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;C&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;No&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the current output which is almost correct:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Outputs.PNG" style="width: 478px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34187iEA1452DB6D4A65C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Outputs.PNG" alt="Outputs.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 23:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606605#M8351</guid>
      <dc:creator>cassylovescats</dc:creator>
      <dc:date>2019-11-22T23:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606609#M8352</link>
      <description>&lt;P&gt;You should really show the code with messages from the log when getting unexpected output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 23:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606609#M8352</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-22T23:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606612#M8353</link>
      <description>&lt;P&gt;Apologies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe this is where the error is. (Observations = 20)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LogOutput.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34189iA3DC3EBFF58EE8B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="LogOutput.PNG" alt="LogOutput.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 23:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606612#M8353</guid>
      <dc:creator>cassylovescats</dc:creator>
      <dc:date>2019-11-22T23:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606616#M8354</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294326"&gt;@cassylovescats&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Apologies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe this is where the error is. (Observations = 20)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LogOutput.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34189iA3DC3EBFF58EE8B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="LogOutput.PNG" alt="LogOutput.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you likely need to look very closely at your data before the Proc Sort step and afterwards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or share your full data set SugarLong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 00:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606616#M8354</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-23T00:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606617#M8355</link>
      <description>&lt;P&gt;To properly diagnose this, we would need to see Data set&amp;nbsp;&lt;SPAN&gt;SugarLongResultDupe.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You show us some data, but it's not clear what data you are showing us.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 00:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606617#M8355</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-23T00:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606620#M8356</link>
      <description>&lt;P&gt;Why are you making an array named MON that includes variables like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SoilID&amp;nbsp;Area&amp;nbsp;Age HarvestMonth HarvestDuration&amp;nbsp;TonnHect Fibre&amp;nbsp;Sugar&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It looks to me like the reason you are seeing 20 instead of 15 is because for some DISTRICTPOSITION you have some observations with YES and some with NO.&amp;nbsp;&amp;nbsp;Is it possible that the same DISTRICTPOSITION value appears in more than one DISTRICT value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to calculate the YES/NO rule so that the values are the same for all observations from the same district? Perhaps you want to SUM the COUNT variable over all of the months, or take the MAX over all of the months? If so then there was no need to transpose it at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 00:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606620#M8356</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-23T00:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606624#M8357</link>
      <description>&lt;P&gt;That is exactly the issue I am finding.&lt;/P&gt;&lt;P&gt;I needed to transpose because I need to run chi-square, I have the mon because I copied the code from another forum and it worked. I am awful at SAS and just need to do this for a final presentation.&lt;/P&gt;&lt;P&gt;I made these codes one by one until it got to this result, I am not really sure how to backtrack at this point.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 00:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606624#M8357</guid>
      <dc:creator>cassylovescats</dc:creator>
      <dc:date>2019-11-23T00:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq Double Counting Certain Outputs</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606648#M8359</link>
      <description>&lt;P&gt;Post the first file you used, namely&amp;nbsp;&lt;SPAN&gt;'~/my_courses/Homework/FinalHomework/CaneData2.csv/'.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Art, CEO, AnalystFinder.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 02:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Proc-Freq-Double-Counting-Certain-Outputs/m-p/606648#M8359</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-11-23T02:43:12Z</dc:date>
    </item>
  </channel>
</rss>

