<?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: data first(keep = major_ag ag_abbr first_year)       last(keep = major_ag ag_abbr last_year); in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747356#M234554</link>
    <description>&lt;P&gt;I believe the statement you want is OTHERWISE.&amp;nbsp; Like the below.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first(keep = major_ag ag_abbr first_year)
last(keep = major_ag ag_abbr last_year);
length major_ag $2;
set Data_Rep.c_agency;
major_ag = substr(ag_code,1,2);
select (major_ag);
when ('03') ag_abbr = 'HHS';
when ('06') ag_abbr = 'NSF';
when ('02') ag_abbr = 'DOD';
when ('04') ag_abbr = 'DOE';
when ('05') ag_abbr = 'NASA';
when ('01') ag_abbr = 'USDA';
when ('19') ag_abbr = 'ED';
when ('08') ag_abbr = 'DOC';
otherwise ag_abbr = 'OTHER';
end;
output first;
output last;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jun 2021 14:39:16 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2021-06-11T14:39:16Z</dc:date>
    <item>
      <title>data first(keep = major_ag ag_abbr first_year)       last(keep = major_ag ag_abbr last_year);    len</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747352#M234550</link>
      <description>&lt;P&gt;data first(keep = major_ag ag_abbr first_year)&lt;BR /&gt;last(keep = major_ag ag_abbr last_year);&lt;BR /&gt;length major_ag $2;&lt;BR /&gt;set Data_Rep.c_agency;&lt;BR /&gt;major_ag = substr(ag_code,1,2);&lt;BR /&gt;select (major_ag);&lt;BR /&gt;when ('03') ag_abbr = 'HHS';&lt;BR /&gt;when ('06') ag_abbr = 'NSF';&lt;BR /&gt;when ('02') ag_abbr = 'DOD';&lt;BR /&gt;when ('04') ag_abbr = 'DOE';&lt;BR /&gt;when ('05') ag_abbr = 'NASA';&lt;BR /&gt;when ('01') ag_abbr = 'USDA';&lt;BR /&gt;when ('19') ag_abbr = 'ED';&lt;BR /&gt;when ('08') ag_abbr = 'DOC';&lt;BR /&gt;end;&lt;BR /&gt;output first;&lt;BR /&gt;output last;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I am trying to also get the agencies that are not 03,06,02,04,05,01,08, and 19 in as Other agencies. I am not sure where to place that when statement in the same code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 14:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747352#M234550</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2021-06-11T14:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: data first(keep = major_ag ag_abbr first_year)       last(keep = major_ag ag_abbr last_year);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747355#M234553</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181538"&gt;@mauri0623&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just add&amp;nbsp;&lt;/P&gt;
&lt;P&gt;otherwise ag_abbr = 'Other Agencies'&lt;/P&gt;
&lt;P&gt;after the last when&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 14:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747355#M234553</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2021-06-11T14:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: data first(keep = major_ag ag_abbr first_year)       last(keep = major_ag ag_abbr last_year);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747356#M234554</link>
      <description>&lt;P&gt;I believe the statement you want is OTHERWISE.&amp;nbsp; Like the below.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first(keep = major_ag ag_abbr first_year)
last(keep = major_ag ag_abbr last_year);
length major_ag $2;
set Data_Rep.c_agency;
major_ag = substr(ag_code,1,2);
select (major_ag);
when ('03') ag_abbr = 'HHS';
when ('06') ag_abbr = 'NSF';
when ('02') ag_abbr = 'DOD';
when ('04') ag_abbr = 'DOE';
when ('05') ag_abbr = 'NASA';
when ('01') ag_abbr = 'USDA';
when ('19') ag_abbr = 'ED';
when ('08') ag_abbr = 'DOC';
otherwise ag_abbr = 'OTHER';
end;
output first;
output last;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 14:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-first-keep-major-ag-ag-abbr-first-year-last-keep-major-ag/m-p/747356#M234554</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-06-11T14:39:16Z</dc:date>
    </item>
  </channel>
</rss>

