<?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 How to Count a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146634#M38920</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have a question I don’t really know how to phrase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called course_id that contains the identification for all participants who have gone through a training at a different site. There are multiple different training sites and therefore multiple course_ids that correlate to those different sites. I would like to run a chi square analysis on the number different training sites, but when I use the course_id variable it does not combine similar sites, but instead gives me the number of participants. In those sites via their course_id. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering if there was a way to count the number of training instead of the total number of participants via using the course_id variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if I have the following data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;course_id&amp;nbsp;&amp;nbsp;&amp;nbsp; location_of_site&lt;/P&gt;&lt;P&gt;00211&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;00211&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;00211&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;33455&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urban&lt;/P&gt;&lt;P&gt;33455&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urban&lt;/P&gt;&lt;P&gt;33455&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urban&lt;/P&gt;&lt;P&gt;66778&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;66778&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;number_trainings_rural&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number_trainings_urban&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I gave enough information and made this clear enough to understand my goal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Donald S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Sep 2014 15:35:27 GMT</pubDate>
    <dc:creator>daszlosek</dc:creator>
    <dc:date>2014-09-16T15:35:27Z</dc:date>
    <item>
      <title>How to Count a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146634#M38920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have a question I don’t really know how to phrase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called course_id that contains the identification for all participants who have gone through a training at a different site. There are multiple different training sites and therefore multiple course_ids that correlate to those different sites. I would like to run a chi square analysis on the number different training sites, but when I use the course_id variable it does not combine similar sites, but instead gives me the number of participants. In those sites via their course_id. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering if there was a way to count the number of training instead of the total number of participants via using the course_id variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if I have the following data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;course_id&amp;nbsp;&amp;nbsp;&amp;nbsp; location_of_site&lt;/P&gt;&lt;P&gt;00211&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;00211&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;00211&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;33455&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urban&lt;/P&gt;&lt;P&gt;33455&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urban&lt;/P&gt;&lt;P&gt;33455&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urban&lt;/P&gt;&lt;P&gt;66778&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;66778&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rural&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;number_trainings_rural&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number_trainings_urban&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I gave enough information and made this clear enough to understand my goal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Donald S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 15:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146634#M38920</guid>
      <dc:creator>daszlosek</dc:creator>
      <dc:date>2014-09-16T15:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146635#M38921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;select location_of_site, count(distinct course_id) as no&lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;group by location_of_site&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 15:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146635#M38921</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-09-16T15:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146636#M38922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you reduce your data down to a single dimension, I don't think there is any way to compute a chi-square from that.&amp;nbsp; Perhaps this alternative is what you are looking for.&amp;nbsp; Reduce the data down to two dimensions, eliminating the counting of participants.&amp;nbsp; Then try for a chi-square on the remaining data.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tables course_id * location_of_site / noprint out=counts;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=counts;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; tables course_id * location_of_site /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chisq;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first PROC FREQ generates COUNTS, holding a single record for each combination of COURSE_ID / LOCATION_OF_SITE.&amp;nbsp; The second PROC FREQ uses that as input to compute chi square statistics.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 15:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146636#M38922</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-09-16T15:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146637#M38923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, this is exactly that I am looking for! Wonderful, thank you Astounding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 16:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-Count-a-variable/m-p/146637#M38923</guid>
      <dc:creator>daszlosek</dc:creator>
      <dc:date>2014-09-16T16:08:13Z</dc:date>
    </item>
  </channel>
</rss>

