<?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: Searching Large Data Set for Specific Codes - Simplify Coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446877#M283272</link>
    <description>&lt;P&gt;This is not a reply to the question. Seek to know how to render the PROC PRINT output in the form Cynthia_sas has done. I used to cut and paste the Proc print's output here, which happens to be mere text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 17:19:04 GMT</pubDate>
    <dc:creator>KachiM</dc:creator>
    <dc:date>2018-03-19T17:19:04Z</dc:date>
    <item>
      <title>Searching Large Data Set for Specific Codes - Simplify Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446631#M283268</link>
      <description>&lt;P&gt;I would like to search a very large SAS dataset (hospital discharge) for specific ICD-10 codes. I have the list of ICD-10 codes I would like to search for in excel. Is there a simple way to go about doing this? I previously used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data SA2009 out2;&lt;BR /&gt;set ED2009;&lt;BR /&gt;if DX1 in ('2910', '2911', '2912', '2913', '2914', '2915', '29181', '29182', '29189')&lt;/P&gt;&lt;P&gt;then output SA2009;&lt;BR /&gt;else output out2;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I had hundreds of codes included in the parentheses. I pasted these in, but then had to had the single quotations and adjust spacing, which took a significant amount of time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to be able to reference the excel doc with all the codes or write code that would not require I manually type each diagnosis code in.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions are appreciated!&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 22:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446631#M283268</guid>
      <dc:creator>erinmurray</dc:creator>
      <dc:date>2018-03-18T22:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Large Data Set for Specific Codes - Simplify Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446635#M283269</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Consider this example...SASHELP.CLASS has 19 rows, where the ages vary from 11 to 16. If I have this file (created here with DATALINES but could have been created from importing an EXCEL list):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need_ages;
  infile datalines;
  input age;
return;
datalines;
13
15
16
;
run;
proc sort data=sashelp.class out=class;
  by age;
run;

proc sort data=need_ages;
  by age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now the file need_ages has the 3 values for AGE that I want to extract from SASHELP.CLASS. My copy of SASHELP.CLASS is not sorted by AGE, so I needed to sort it first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, I do a merge to essentially "split" the file into 2 separate files -- one with the observations that have the age I want and the other that are the rows for other ages that I don't want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the MERGE code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data got_ages not_these;
  merge need_ages(in=need) class(in=allrec);
  by age;
  if need=1 and allrec=1 then output got_ages;
  else if allrec = 1 and need=0 then output not_these;
run;

proc print data=got_ages;
  title '1) Only wanted ages 13, 15 and 16';
run;

proc print data=not_these;
  title '2) Did NOT want these rows because they are not in the ages list';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And here are the results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="concept_of_merge.png" style="width: 455px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19276i84BE06CC628CDC03/image-size/large?v=v2&amp;amp;px=999" role="button" title="concept_of_merge.png" alt="concept_of_merge.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also do this with an SQL join, which might be easier. but you only get 1 file for each SQL step. The SQL has the advantage of not needing to sort the files. This example also uses WORK.NEED_AGES:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
  create table work.sq_join_age as
  select b.name, b.age, b.sex, b.height, b.weight
  from need_ages a, sashelp.class b
  where a.age = b.age
  order by b.age;
quit;

proc print data=sq_join_age;
  title '3) Using an SQL join';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the downside is that if you need a dataset with the nonmatches, you have to run a second SQL step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 22:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446635#M283269</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-03-18T22:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Large Data Set for Specific Codes - Simplify Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446642#M283270</link>
      <description>&lt;P&gt;Do you really need the data set OUT2?&amp;nbsp; If not, you can do this in one step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table SA2009 as&lt;/P&gt;
&lt;P&gt;select * from ED2009&lt;/P&gt;
&lt;P&gt;where dx in (select values from excel_list);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to modify the interior SELECT clause, using the real name of the data set and variable holding the list of codes from Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether this is helpful or not, the techniques that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;posted are required learning if you want to program in SAS.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 23:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446642#M283270</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-18T23:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Large Data Set for Specific Codes - Simplify Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446726#M283271</link>
      <description>&lt;P&gt;As long as your total IN clause does not go above 64K, and assuming you can read your Excel file into a SAS data set, something like this should do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select quote(trim(code),"'") into :codes separated by ',' from &amp;lt;your Excel data&amp;gt;;
quit;

data SA2009 out2;
  set ED2009;
  if DX1 in(&amp;amp;codes) then....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I put the "'" in the quote function in case some of your codes contain "&amp;amp;" or "%", which would&amp;nbsp;be interpreted as macro tokens if the codes were in double quotes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 11:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446726#M283271</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-03-19T11:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Large Data Set for Specific Codes - Simplify Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446877#M283272</link>
      <description>&lt;P&gt;This is not a reply to the question. Seek to know how to render the PROC PRINT output in the form Cynthia_sas has done. I used to cut and paste the Proc print's output here, which happens to be mere text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 17:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446877#M283272</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2018-03-19T17:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Large Data Set for Specific Codes - Simplify Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446879#M283273</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; I used the Photos button under Reply (note, if you choose "Quick Reply" you do not have the opportunity to post either code or pictures).&lt;BR /&gt;&lt;BR /&gt; To make the screen shots, sometimes I use FullShot, sometimes GreenShot and sometimes the Windows Snipping tool and sometimes just Prnt Scr. To add arrows, comments, etc to images, I alternate between using FullShot and pasting the image in PowerPoint and adding arrows and text with PPT (which requires usually taking another screen shot of the final PPT file).&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 17:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-Large-Data-Set-for-Specific-Codes-Simplify-Coding/m-p/446879#M283273</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-03-19T17:42:17Z</dc:date>
    </item>
  </channel>
</rss>

