<?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: DS2 suminc how to do? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846950#M334841</link>
    <description>&lt;P&gt;This code does not run properly as shown here. The DATA step with the hash object produces this error message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;85               length COUNT 8;
 86                  declare hash h (suminc:1, keysum:'COUNT');
 87                  h.definekey ('X');
 88                  h.definedone ();
 89            end;
 90            h.ref ();
 91            if eof then h.output (dataset: 'table_output');
 92         run;
 
 NOTE: Variable COUNT is uninitialized.
 ERROR: Type mismatch for method parameter 1 at line 86 column 25.
 ERROR: Expecting Character type.
 ERROR: DATA STEP Component Object failure.  Aborted during the EXECUTION phase.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: There were 2 observations read from the data set WORK.TABLE_INPUT.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Suminc: requires the name of a variable as input. Can you explain exactly what are you trying to accomplish with this code? What output do you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2022 00:32:07 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2022-11-30T00:32:07Z</dc:date>
    <item>
      <title>DS2 suminc how to do?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846919#M334817</link>
      <description>&lt;P&gt;In regular 4gl I do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data table_input;
    X = 7; output;
    X = 3; output;
    X = 7; output;
    X = 2; output;
    X = 7; output;
    X = 4; output;
    X = 7; output;
    X = 4; output;
    X = 3; output;
    X = 7; output;
run;

data _null_;
   set table_input end = eof;
   if _n_ = 1 then do;
      length COUNT 8;
         declare hash h (suminc:1, keysum:'COUNT');
         h.definekey ('X');
         h.definedone ();
   end;
   h.ref ();
   if eof then h.output (dataset: 'table_output');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the number of occurrences of the variable X as the results. It's ok.&lt;/P&gt;&lt;P&gt;How to do it in DS2? There is no keysum variable in DS2, I don't know how to add a Count that has the number of occurrences of X in the output table.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 20:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846919#M334817</guid>
      <dc:creator>ciaran2</dc:creator>
      <dc:date>2022-11-29T20:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 suminc how to do?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846950#M334841</link>
      <description>&lt;P&gt;This code does not run properly as shown here. The DATA step with the hash object produces this error message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;85               length COUNT 8;
 86                  declare hash h (suminc:1, keysum:'COUNT');
 87                  h.definekey ('X');
 88                  h.definedone ();
 89            end;
 90            h.ref ();
 91            if eof then h.output (dataset: 'table_output');
 92         run;
 
 NOTE: Variable COUNT is uninitialized.
 ERROR: Type mismatch for method parameter 1 at line 86 column 25.
 ERROR: Expecting Character type.
 ERROR: DATA STEP Component Object failure.  Aborted during the EXECUTION phase.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: There were 2 observations read from the data set WORK.TABLE_INPUT.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Suminc: requires the name of a variable as input. Can you explain exactly what are you trying to accomplish with this code? What output do you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 00:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846950#M334841</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-11-30T00:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 suminc how to do?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846976#M334849</link>
      <description>&lt;P&gt;Maybe it depends on the server settings, but on my machine this code works :).&lt;/P&gt;&lt;P&gt;I have SAS 9.4.6.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: Variable COUNT is uninitialized.
NOTE: The data set WORK.TABLE_OUTPUT has 4 observations and 2 variables.
NOTE: There were 10 observations read from the data set WORK.TABLE_INPUT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Table table_output:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;COUNT&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/SPAN&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;In the output I have the number of observations X in the table_input set.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 06:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-suminc-how-to-do/m-p/846976#M334849</guid>
      <dc:creator>ciaran2</dc:creator>
      <dc:date>2022-11-30T06:42:02Z</dc:date>
    </item>
  </channel>
</rss>

