<?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: Count Function in SPSS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893831#M353095</link>
    <description>I thought of using CAT but did not like that for my purposes.&lt;BR /&gt;</description>
    <pubDate>Tue, 12 Sep 2023 15:49:21 GMT</pubDate>
    <dc:creator>Zad</dc:creator>
    <dc:date>2023-09-12T15:49:21Z</dc:date>
    <item>
      <title>Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893760#M353077</link>
      <description>&lt;P&gt;is there a function similar to Count in SPSS other than the SAS macro %COUNT created by&amp;nbsp;Jim Groeneveld, OCS Biometric Support, the Netherlands in 2008?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is a video of what Count does in SPSS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.google.com/search?q=SPSS+COUNT&amp;amp;rlz=1C1CHBD_enUS919US919&amp;amp;oq=SPSS+COUNT&amp;amp;aqs=chrome..69i57.3310j0j1&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8#fpstate=ive&amp;amp;vld=cid:adb1d6d1,vid:YQSKLLlJSeg,st:0" target="_blank"&gt;https://www.google.com/search?q=SPSS+COUNT&amp;amp;rlz=1C1CHBD_enUS919US919&amp;amp;oq=SPSS+COUNT&amp;amp;aqs=chrome..69i57.3310j0j1&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8#fpstate=ive&amp;amp;vld=cid:adb1d6d1,vid:YQSKLLlJSeg,st:0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 12:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893760#M353077</guid>
      <dc:creator>Zad</dc:creator>
      <dc:date>2023-09-12T12:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893770#M353080</link>
      <description>&lt;P&gt;Some of us can't actually view external videos from our work computer (firewall prevents us from doing so). Why don't you just tell us what this function does?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 13:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893770#M353080</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-12T13:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893794#M353086</link>
      <description>&lt;P&gt;I don't really know.&amp;nbsp; SPSS has this syntax&amp;nbsp;&lt;BR /&gt;COUNT Count4J=PSTATE_ADVEN_r FUN POWER(4).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From what I can tell it does this, for every entry of a 4 in the variable list count.&amp;nbsp; I will have to confirm by running in SPSS and the code below in SAS to compare the results.&lt;BR /&gt;if PSTATE_ADVEN_r=4 and FUN^=4 and POWER^=4 then count4J=1;&lt;BR /&gt;else if PSTATE_ADVEN_r^=4 and FUN=4 and POWER^=4 then count4J=1;&lt;BR /&gt;else if PSTATE_ADVEN_r^=4 and FUN^=4 and POWER=4 then count4J=1;&lt;BR /&gt;else if PSTATE_ADVEN_r=4 and FUN=4 and POWER^=4 then count4J=2;&lt;BR /&gt;else if PSTATE_ADVEN_r^=4 and FUN=4 and POWER=4 then count4J=2;&lt;BR /&gt;else if PSTATE_ADVEN_r=4 and FUN^=4 and POWER=4 then count4J=2;&lt;BR /&gt;else if PSTATE_ADVEN_r=4 and FUN=4 and POWER=4 then count4J=3;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 14:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893794#M353086</guid>
      <dc:creator>Zad</dc:creator>
      <dc:date>2023-09-12T14:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893803#M353091</link>
      <description>&lt;P&gt;Crappy video link. It is better to point to software document links.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Freq will count the number of observations with each value in the data set.&lt;/P&gt;
&lt;P&gt;If you have a SAS install then you should be able to run this code as the SASHELP.CLASS data set is provided by default for training.&lt;/P&gt;
&lt;PRE&gt;Proc freq data= sashelp.class;
   tables sex age;  /*&amp;lt;- this "counts" the values of the variables in one dimension*/
  tables sex*age; /* counts in two dimensions, the intersections of the sex and age values*/
  tables sex*age / list;  /* displays two dimensions as a single row*/

/* and a different procedure*/
Proc tabulate data=sashelp.class;
   class sex age;
   tables sex,
             age*n;
  tables sex*age,
            n;
run;&lt;/PRE&gt;
&lt;P&gt;Procedures Report and Means/Summary can also provide counts. Many analysis procedures will provide a data summary that may show value counts as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, that SPSS and SAS both have multiple ways to "count" just about anything. The details of what is needed will point to which procedure and/or options may be needed.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 14:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893803#M353091</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-12T14:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893810#M353093</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162861"&gt;@Zad&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p02vuhb5ijuirbn1p7azkyianjd8.htm" target="_blank" rel="noopener"&gt;COUNT function&lt;/A&gt; or in some cases the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1qcntq4r6p3w3n1mtsnm58tbomc.htm" target="_blank" rel="noopener"&gt;COUNTC function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do PSTATE_ADVEN_r=0.4, 4;
  do FUN=-4, 4;
    do POWER=4, 44;
      output;
    end;
  end;
end;
run;

data want;
set have;
n4=count(catx('||','#',PSTATE_ADVEN_r,FUN,POWER,'#'),'|4|');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The COUNTC function would not work in the above example (but in others where, e.g., all values have length 1) because of the occurrence of digit 4 in values other than 4.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 15:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893810#M353093</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-09-12T15:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893831#M353095</link>
      <description>I thought of using CAT but did not like that for my purposes.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Sep 2023 15:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893831#M353095</guid>
      <dc:creator>Zad</dc:creator>
      <dc:date>2023-09-12T15:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Count Function in SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893844#M353102</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162861"&gt;@Zad&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I don't really know.&amp;nbsp; SPSS has this syntax&amp;nbsp;&lt;BR /&gt;COUNT Count4J=PSTATE_ADVEN_r FUN POWER(4).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what I can tell it does this, for every entry of a 4 in the variable list count.&amp;nbsp; I will have to confirm by running in SPSS and the code below in SAS to compare the results.&lt;BR /&gt;if PSTATE_ADVEN_r=4 and FUN^=4 and POWER^=4 then count4J=1;&lt;BR /&gt;else if PSTATE_ADVEN_r^=4 and FUN=4 and POWER^=4 then count4J=1;&lt;BR /&gt;else if PSTATE_ADVEN_r^=4 and FUN^=4 and POWER=4 then count4J=1;&lt;BR /&gt;else if PSTATE_ADVEN_r=4 and FUN=4 and POWER^=4 then count4J=2;&lt;BR /&gt;else if PSTATE_ADVEN_r^=4 and FUN=4 and POWER=4 then count4J=2;&lt;BR /&gt;else if PSTATE_ADVEN_r=4 and FUN^=4 and POWER=4 then count4J=2;&lt;BR /&gt;else if PSTATE_ADVEN_r=4 and FUN=4 and POWER=4 then count4J=3;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I see that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; has given you a correct answer. However, for the future, I point out that an answer of "I don't really know" doesn't really advance our understanding and doesn't move us closer to providing help. SPSS syntax doesn't advance our understanding either. Either show us documentation for this COUNT function, or figure it out enough so you can explain.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 16:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Function-in-SPSS/m-p/893844#M353102</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-12T16:32:49Z</dc:date>
    </item>
  </channel>
</rss>

