<?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 PROC SQL GROUP BY STATE AND COUNTY FIPS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-BY-STATE-AND-COUNTY-FIPS/m-p/916389#M83323</link>
    <description>&lt;P&gt;I am working on a nationwide dataset where has my outcome variable at both county and state level. ealier I used PROC SQL&amp;nbsp; and group by statement to get a total deaths by state and here is my code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; &lt;BR /&gt;create table test1 as select *, count(*) as total_deaths from aggregatedallv1 group by State_Occurrence_FIPS&amp;nbsp; quit;&lt;/P&gt;
&lt;P&gt;this gave me a columns as total per State. Now I wonder how to get total per county group by State.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any advice is much appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 01:54:26 GMT</pubDate>
    <dc:creator>raheleh22</dc:creator>
    <dc:date>2024-02-16T01:54:26Z</dc:date>
    <item>
      <title>PROC SQL GROUP BY STATE AND COUNTY FIPS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-BY-STATE-AND-COUNTY-FIPS/m-p/916389#M83323</link>
      <description>&lt;P&gt;I am working on a nationwide dataset where has my outcome variable at both county and state level. ealier I used PROC SQL&amp;nbsp; and group by statement to get a total deaths by state and here is my code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; &lt;BR /&gt;create table test1 as select *, count(*) as total_deaths from aggregatedallv1 group by State_Occurrence_FIPS&amp;nbsp; quit;&lt;/P&gt;
&lt;P&gt;this gave me a columns as total per State. Now I wonder how to get total per county group by State.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any advice is much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 01:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-BY-STATE-AND-COUNTY-FIPS/m-p/916389#M83323</guid>
      <dc:creator>raheleh22</dc:creator>
      <dc:date>2024-02-16T01:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL GROUP BY STATE AND COUNTY FIPS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-BY-STATE-AND-COUNTY-FIPS/m-p/916391#M83324</link>
      <description>&lt;P&gt;Assuming that in your source table HAVE you've got one row per death and you've got a variable for state and one for county then code along the line of below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table test1 as 
    select 
      state
      ,county 
      ,count(*) as total_deaths 
    from have 
    group by state, county
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to get aggregated values (count, sum, ...) on different level (like state and state,county) using a single Proc then look into Proc Means.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 03:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-GROUP-BY-STATE-AND-COUNTY-FIPS/m-p/916391#M83324</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-16T03:04:02Z</dc:date>
    </item>
  </channel>
</rss>

