<?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: How to restrict proc sql to pick up current data? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782051#M249290</link>
    <description>&lt;P&gt;This looks as much a database design problem as anything else.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see subject name, pay code, stream code, start date and end date all both tables, which looks bad on the face of it from here.&amp;nbsp; A table structure with a student table (primary key student id, perhaps demographic elements) and an employment table (multiple records per student allowed, with start dates, end dates, stream, and pay code for each record) might make things easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps some sample data could be provided and the desired result shown based on the provided data?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Nov 2021 19:13:05 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2021-11-23T19:13:05Z</dc:date>
    <item>
      <title>How to restrict proc sql to pick up current data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/781995#M249260</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
&lt;P&gt;A student is currently enrolled in Management Stream with a start date of 08/28/2021 and end date of 12/31/2021. &lt;BR /&gt;The student is switching stream from Science(S) to Management (M),&amp;nbsp; paycode is also changing from 'H'(current)&amp;nbsp; to&amp;nbsp; 'L'(future)&amp;nbsp;with a start date of 01/01/2022 and end date of 12/31/2026.&lt;/P&gt;
&lt;P&gt;An Access database table has been maintained with two start dates(08/28/2021 and 08/01/2022), two end dates(12/31/2021 and 12/31/2026), two streams ('S' and 'M') and two pay codes ('H' and 'L')&amp;nbsp; to account for the upcoming changes. &lt;BR /&gt;The problem is the logic below is picking up (or probably mixing things up) the start dates, end dates, streams and pay codes randomly and thus producing fallouts(indicating errors/mismatch).&lt;BR /&gt;Is there a way to force the logic/code to restrict it to look at the start and end dates, stream and paycode to the current records (08/28/2021,12/31/2021,'S','H') until 12/31/2021? &lt;BR /&gt;And also need to tell it to check future records (01/1/2022,12/31/2026,'M','L') ON or AFTER&amp;nbsp; 01/01/2022.&lt;BR /&gt;Any help/idea is greatly appreciated.&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table detail as&lt;BR /&gt;select distinct &lt;BR /&gt;a.student_ID, &lt;BR /&gt;case when b.studentId = '' then 'Row not found in StudentInfo' else '' end as Row_Check,&lt;BR /&gt;case when b.studentId ^= '' and a.subject_name ^= b.SubjName then 'Unmatched Subject Name' else '' end as Subject_Check,&lt;BR /&gt;case when b.studentId ^= '' and a.pay_code ^= b.paycode then 'Unmatched Pay Code' else '' end as PayCode_Check,&lt;BR /&gt;case when b.studentId ^= '' and a.stream_code ^= b.Streamcode then 'Unmatched Stream Code' else '' end as Stream_Check,&lt;BR /&gt;case when b.studentId ^= '' and (a.start_date &amp;lt; b.StartDate) or (a.end_date &amp;gt; b.EndDate) then 'Date Range not Allowed' else '' end as EnrollmentDate_Check,&lt;BR /&gt;a.student_name,&lt;BR /&gt;a.subject_name,&lt;BR /&gt;a.start_date,&lt;BR /&gt;a.end_date, &lt;BR /&gt;a.pay_code &lt;BR /&gt;from student_data a&lt;BR /&gt;left join StudentInfo b&lt;BR /&gt;on b.studentId = a.Student_ID and b.section = a.section &lt;BR /&gt;having row_check ^= '' or Subject_Check ^= '' or Paycode_Check ^= '' &lt;BR /&gt;or Stream_Check ^= '' or EnrollmentDate_Check ^= ''&lt;BR /&gt;order by a.student_ID, a.Student_Name;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 16:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/781995#M249260</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-11-23T16:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict proc sql to pick up current data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782051#M249290</link>
      <description>&lt;P&gt;This looks as much a database design problem as anything else.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see subject name, pay code, stream code, start date and end date all both tables, which looks bad on the face of it from here.&amp;nbsp; A table structure with a student table (primary key student id, perhaps demographic elements) and an employment table (multiple records per student allowed, with start dates, end dates, stream, and pay code for each record) might make things easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps some sample data could be provided and the desired result shown based on the provided data?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 19:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782051#M249290</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2021-11-23T19:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict proc sql to pick up current data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782143#M249324</link>
      <description>&lt;P&gt;what's variable SECTION ?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 07:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782143#M249324</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-24T07:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict proc sql to pick up current data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782165#M249336</link>
      <description>&lt;P&gt;Please supply example data for both datasets that covers all possible combinations of interest. Use &lt;U&gt;working&lt;/U&gt; data steps with datalines, NOTHING else. Post the codes using the "little running man" button (right next to the one indicated).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/8D8B612AA6AB1DC7E9A0812281D56E02/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 08:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-proc-sql-to-pick-up-current-data/m-p/782165#M249336</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-24T08:54:01Z</dc:date>
    </item>
  </channel>
</rss>

