<?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: Feeding the top 25 diagnoses into the next program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599914#M173274</link>
    <description>&lt;P&gt;Take advantage of BY processing, instead of macro processing. It's more efficient and easier to code. Here is an example calculating the median weight of students from the top three age groups, for each sex :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.class out=class; 
by sex age; 
run;

proc freq data=class order=freq;
by sex;
tables age/noprint out=counts;
run;
 
data keep;
do i = 1 by 1 until(last.sex);
   set counts; by sex;
   if i &amp;lt;= 3 then output;
   end;
drop i percent;
run;

data select;
merge class keep(in=ok);
by sex age;
if ok;
run;

proc means data=select noprint;
by sex;
var weight;
output out=medians median=med;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Oct 2019 19:17:58 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-10-28T19:17:58Z</dc:date>
    <item>
      <title>Feeding the top 25 diagnoses into the next program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599888#M173263</link>
      <description>&lt;P&gt;I have code like this (see below) where I get the top 25 diagnoses:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;proc freq data=&amp;amp;dataems order=freq;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tables diag1CCS/noprint out=counts;&lt;BR /&gt;&amp;nbsp;run;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;data state;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set counts (obs=25);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; drop percent;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Then I want to write another program to go back to my original data (&amp;amp;dataems) and keep only the records with the top 25 diag1ccs categories.&amp;nbsp; How could I do that without having to copy and paste the top 25 diag1ccs categories into another data step?&amp;nbsp; I want a more automated process, because I will end up having to do this over 100 times.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Thanks for your help.&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 28 Oct 2019 18:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599888#M173263</guid>
      <dc:creator>hein68</dc:creator>
      <dc:date>2019-10-28T18:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Feeding the top 25 diagnoses into the next program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599891#M173266</link>
      <description>&lt;P&gt;Please refer to following two papers :&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/249-31.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/249-31.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi30/001-30.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi30/001-30.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 18:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599891#M173266</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2019-10-28T18:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Feeding the top 25 diagnoses into the next program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599897#M173269</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74483"&gt;@hein68&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have code like this (see below) where I get the top 25 diagnoses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT&gt;proc freq data=&amp;amp;dataems order=freq;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tables diag1CCS/noprint out=counts;&lt;BR /&gt;&amp;nbsp;run;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;data state;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set counts (obs=25);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; drop percent;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Then I want to write another program to go back to my original data (&amp;amp;dataems) and keep only the records with the top 25 diag1ccs categories.&amp;nbsp; How could I do that without having to copy and paste the top 25 diag1ccs categories into another data step?&amp;nbsp; I want a more automated process, because I will end up having to do this over 100 times.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Thanks for your help.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about PROC SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table new as select * from &amp;amp;dataems 
        where diag1ccs in (Select distinct diag1ccs from state);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 18:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599897#M173269</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-28T18:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Feeding the top 25 diagnoses into the next program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599903#M173272</link>
      <description>&lt;P&gt;Is diagnosis a single file or do you need to search all 25 (usual number) of diagnosis fields?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74483"&gt;@hein68&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have code like this (see below) where I get the top 25 diagnoses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT&gt;proc freq data=&amp;amp;dataems order=freq;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tables diag1CCS/noprint out=counts;&lt;BR /&gt;&amp;nbsp;run;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;data state;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set counts (obs=25);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; drop percent;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Then I want to write another program to go back to my original data (&amp;amp;dataems) and keep only the records with the top 25 diag1ccs categories.&amp;nbsp; How could I do that without having to copy and paste the top 25 diag1ccs categories into another data step?&amp;nbsp; I want a more automated process, because I will end up having to do this over 100 times.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Thanks for your help.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 18:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599903#M173272</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-28T18:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Feeding the top 25 diagnoses into the next program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599913#M173273</link>
      <description>&lt;P&gt;This is great!&amp;nbsp; Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 19:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599913#M173273</guid>
      <dc:creator>hein68</dc:creator>
      <dc:date>2019-10-28T19:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Feeding the top 25 diagnoses into the next program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599914#M173274</link>
      <description>&lt;P&gt;Take advantage of BY processing, instead of macro processing. It's more efficient and easier to code. Here is an example calculating the median weight of students from the top three age groups, for each sex :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.class out=class; 
by sex age; 
run;

proc freq data=class order=freq;
by sex;
tables age/noprint out=counts;
run;
 
data keep;
do i = 1 by 1 until(last.sex);
   set counts; by sex;
   if i &amp;lt;= 3 then output;
   end;
drop i percent;
run;

data select;
merge class keep(in=ok);
by sex age;
if ok;
run;

proc means data=select noprint;
by sex;
var weight;
output out=medians median=med;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 19:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Feeding-the-top-25-diagnoses-into-the-next-program/m-p/599914#M173274</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-10-28T19:17:58Z</dc:date>
    </item>
  </channel>
</rss>

