<?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: complex query in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31479#M1154</link>
    <description>Some ideas for SAS programming techniques:&lt;BR /&gt;
&lt;BR /&gt;
1) use a SAS format for your look-up on SSN values.&lt;BR /&gt;
2) you can use the INTNX and INTCK functions in the SAS DATA step to increment (loop) through the time-period dates (year) - a DO / END loop could work, depending on your SAS data variable values.&lt;BR /&gt;
3) if you need it, you can pre-load an array with constant values, and use a DATA step code construct to find a match, like below:&lt;BR /&gt;
&lt;BR /&gt;
DO I=1 TO DIM(&lt;ARRAYNAME&gt;);&lt;BR /&gt;
  * your match-test-logic goes here. ;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Suggest you post a small example of your input data, code up a SAS DATA step to read the DATALINES (sample input), creating a SAS file, then begin putting together your overall program,  one small component at a time, and then post a reply to the forum subscribers for feedback and guidance.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/ARRAYNAME&gt;</description>
    <pubDate>Wed, 13 May 2009 19:32:37 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-05-13T19:32:37Z</dc:date>
    <item>
      <title>complex query</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31478#M1153</link>
      <description>Can someone help me build a complex query?&lt;BR /&gt;
I want to go thru all inpatient(ABC files) and outpatient (DEF files) files that we have. They are stored with same name and then FYNN.  I need 10 years worth.&lt;BR /&gt;
So I need it to go thrru each inpatient file by year and see if the ssn matches one in a file of 200k numbers.  If it matches, then I want it to look thru a group of 10 diagnoses and exclude any records with dx 345, 346, or 347.&lt;BR /&gt;
I want to end up with all the records that match the ssn's I was looking for that do NOt have the excluded diagnoses.&lt;BR /&gt;
So how to do the looping for the years and possibly an array of the diagnoses...?</description>
      <pubDate>Wed, 13 May 2009 16:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31478#M1153</guid>
      <dc:creator>Marilyn</dc:creator>
      <dc:date>2009-05-13T16:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: complex query</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31479#M1154</link>
      <description>Some ideas for SAS programming techniques:&lt;BR /&gt;
&lt;BR /&gt;
1) use a SAS format for your look-up on SSN values.&lt;BR /&gt;
2) you can use the INTNX and INTCK functions in the SAS DATA step to increment (loop) through the time-period dates (year) - a DO / END loop could work, depending on your SAS data variable values.&lt;BR /&gt;
3) if you need it, you can pre-load an array with constant values, and use a DATA step code construct to find a match, like below:&lt;BR /&gt;
&lt;BR /&gt;
DO I=1 TO DIM(&lt;ARRAYNAME&gt;);&lt;BR /&gt;
  * your match-test-logic goes here. ;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Suggest you post a small example of your input data, code up a SAS DATA step to read the DATALINES (sample input), creating a SAS file, then begin putting together your overall program,  one small component at a time, and then post a reply to the forum subscribers for feedback and guidance.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/ARRAYNAME&gt;</description>
      <pubDate>Wed, 13 May 2009 19:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31479#M1154</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-13T19:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: complex query</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31480#M1155</link>
      <description>Marilyn,&lt;BR /&gt;
&lt;BR /&gt;
To follow-up on Scott's comments, Rick Langston has a paper that works with look-up techniques:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/037-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/037-2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
It looks like you just have 20 files to examine.  It may be easier to hard-code the concatenation than to build the looping code.&lt;BR /&gt;
&lt;BR /&gt;
The ARRAY approach is the easiest way to go through the 10 diagnosis coded.  In the loop, set a flag for the exclusion; outside the loop, examine the flag to decide to output the record or not.&lt;BR /&gt;
&lt;BR /&gt;
Your expressed request, and this approach, will NOT exclude persons with these diagnoses on ANY encounter.  To do that, output an ID list of the subset with the diagnosis on any encounter and re-merge that with the original set of hits.  That is an easy SQL code:&lt;BR /&gt;
&lt;BR /&gt;
SELECT * FROM keepers&lt;BR /&gt;
WHERE ssn NOT IN (SELECT DISTINCT ssn FROM excludes)&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Thu, 14 May 2009 13:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31480#M1155</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-05-14T13:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: complex query</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31481#M1156</link>
      <description>Thanks&lt;BR /&gt;
I am trying to make the code as efficient as possible too, which is why I thought it might be better to loop through the years  and accumulate everything at the end.&lt;BR /&gt;
I am hoping that I can create a model that we can use repetitvely as well.</description>
      <pubDate>Thu, 14 May 2009 13:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31481#M1156</guid>
      <dc:creator>Marilyn</dc:creator>
      <dc:date>2009-05-14T13:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: complex query</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31482#M1157</link>
      <description>As suggested previously, explore using a DO / END loop to output SAS (numeric) DATE variables, using the INTNX function - see the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website supplemental technical paper (link below) on this topic.&lt;BR /&gt;
&lt;BR /&gt;
Scott  Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS Dates, Times, and Interval Functions&lt;BR /&gt;
Definitions and Explanations&lt;BR /&gt;
SAS Dates, Times, and Datetimes:&lt;BR /&gt;
&lt;A href="http://support.sas.com/techsup/technote/ts668.pdf" target="_blank"&gt;http://support.sas.com/techsup/technote/ts668.pdf&lt;/A&gt;</description>
      <pubDate>Thu, 14 May 2009 17:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31482#M1157</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-14T17:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: complex query</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31483#M1158</link>
      <description>I had to do something similar a while ago.  You can probably tweek the following to your needs.&lt;BR /&gt;
&lt;BR /&gt;
%macro mem_detail_tin_mon;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select distinct tin into :tin1 - :tin48 from req.tins;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select distinct monyr into :mon1 - :mon20 from monthlist;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%do i = 1 %to 48;&lt;BR /&gt;
  %do j = 1 %to 20;&lt;BR /&gt;
data Final;&lt;BR /&gt;
  set req.mem_detail_2;&lt;BR /&gt;
&lt;BR /&gt;
  where tin = "&amp;amp;&amp;amp;tin&amp;amp;i" and monyr = "&amp;amp;&amp;amp;mon&amp;amp;j";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc export data = Final&lt;BR /&gt;
   outtable = "PD_&amp;amp;&amp;amp;tin&amp;amp;i.._&amp;amp;&amp;amp;mon&amp;amp;j.."&lt;BR /&gt;
   dbms = access2000 replace;&lt;BR /&gt;
   database = "X:Req_detail_32808.mdb";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
     %end;&lt;BR /&gt;
  %end;&lt;BR /&gt;
&lt;BR /&gt;
%mend mem_detail_tin_mon;&lt;BR /&gt;
&lt;BR /&gt;
%mem_detail_tin_mon;</description>
      <pubDate>Wed, 01 Jul 2009 20:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/complex-query/m-p/31483#M1158</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-01T20:39:26Z</dc:date>
    </item>
  </channel>
</rss>

