<?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: for each applicant, collect applications appllied by applicants over past 5 years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759658#M240113</link>
    <description>yes, they are the same. Many thanks for your advice. I do not know how to merge these two posts. This post summarizes the question of the previous post.</description>
    <pubDate>Thu, 05 Aug 2021 09:11:47 GMT</pubDate>
    <dc:creator>Alexxxxxxx</dc:creator>
    <dc:date>2021-08-05T09:11:47Z</dc:date>
    <item>
      <title>for each applicant, collect applications appllied by applicants over past 5 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759638#M240104</link>
      <description>&lt;P&gt;&lt;SPAN&gt;For each application_id, I expect to 1) identify the applicant which applied the application_id and then 2) identify application_id which applied by applicants over the past 5 years.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;By using the following data as an example,&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
       infile cards dsd  dlm=",";
       input
       Obs :8.
       Applicant_name :$8.
       application_date: YYMMDD10.
       application_id :8.
       ;
       format
       application_date :YYMMDD10.
       ;
       cards;
       1,A,2021-07-28,101
       2,B,2021-07-28,101
       3,A,2017-07-28,102
       4,A,2016-07-27,103
       5,B,2018-07-28,104
       ;;;;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I expect to have the below result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Obs,Applicant_name,application_date,application_id,applied_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1,A, 2021-07-28, 101, 102&lt;/P&gt;&lt;P&gt;2,B, 2021-07-28, 101, 104&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3,A, 2017-07-28, 102, 103&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4,A, 2016-07-27, 103&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is because, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;For&amp;nbsp;application_id 101&lt;/STRONG&gt;, it is applied by two applicants, which are &lt;STRONG&gt;A &lt;/STRONG&gt;and &lt;STRONG&gt;B&lt;/STRONG&gt;. and then I expect to include application_id &lt;STRONG&gt;102&lt;/STRONG&gt;, because it is applied by applicant A on 2017-07-28, which is &lt;STRONG&gt;within 5 years before 2021-07-28&lt;/STRONG&gt;.&amp;nbsp;&lt;U&gt;I include application_id &lt;STRONG&gt;104&lt;/STRONG&gt; for the same reason (because 1) B applied for application 101 in&amp;nbsp;2021-07-28, 2) B also applied application 104 in&amp;nbsp;2018-07-28,&amp;nbsp; 3) 2018-07-28 within the 5-years before 2021-07-28)&lt;/U&gt;. I do not include application_id 103, because although it is applied by applicant A, it is not applied within 5 years before 2021-07-28.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I am using the code,&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO Explo(year=);
	PROC SQL;
		CREATE TABLE want_p5y_&amp;amp;year. AS
		SELECT DISTINCT
		citing1.Applicant_name,
		citing1.application_date,
		citing1.application_id,
		citing2.application_id as applied_id
		FROM
		have as citing1
		left JOIN have AS citing2 ON citing1.Applicant_name = citing2.Applicant_name
		where citing1.application_id ^= citing2.application_id
		group by citing1.application_date
		having citing2.application_date between intnx('year', min(citing1.application_date), -5, 'S') and citing1.application_date 
		;
	QUIT;
%MEND Explo;
%Explo(year=2021)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I got the result as&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Applicant_name&lt;/TD&gt;&lt;TD&gt;application_date&lt;/TD&gt;&lt;TD&gt;application_id&lt;/TD&gt;&lt;TD&gt;applied_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2017/7/28&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2021/7/28&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2021/7/28&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;104&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem is&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1) I only get 3 rows rather than 4 rows.&lt;/P&gt;&lt;P&gt;2) My dataset has&amp;nbsp;17883455 rows and 3 columns (from 1985 to 2020). It is too big for me. So I split the dataset by year. Even so, when I run the dataset with the above code, I still get the following results&lt;/P&gt;&lt;PRE&gt;ERROR: Insufficient space in file WORK.'SASTMP-000000010'n.UTILITY.
ERROR: File WORK.'SASTMP-000000010'n.UTILITY is damaged. I/O processing did not complete.
NOTE: Error was encountered during utility-file processing. You may be able to execute the SQL
      statement successfully if you allocate more space to the WORK library.&lt;BR /&gt;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 56:41.45&lt;BR /&gt;cpu time 2:14.93&lt;BR /&gt;

&lt;/PRE&gt;&lt;P&gt;Could you please give me some advice to get the expected result? I guess there should be some smart methods to get the result easily and quickly. but I just do not know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for any advice.&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>Thu, 05 Aug 2021 06:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759638#M240104</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2021-08-05T06:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: for each applicant, collect applications appllied by applicants over past 5 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759643#M240107</link>
      <description>&lt;P&gt;Seems to be the same problem as in &lt;A href="https://communities.sas.com/t5/SAS-Programming/for-each-applicaiont-collect-applications-appllied-by-applicants/m-p/757651" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/for-each-applicaiont-collect-applications-appllied-by-applicants/m-p/757651&lt;/A&gt;. Right? I tend to merge both posts ...&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 07:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759643#M240107</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-08-05T07:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: for each applicant, collect applications appllied by applicants over past 5 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759658#M240113</link>
      <description>yes, they are the same. Many thanks for your advice. I do not know how to merge these two posts. This post summarizes the question of the previous post.</description>
      <pubDate>Thu, 05 Aug 2021 09:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-each-applicant-collect-applications-appllied-by-applicants/m-p/759658#M240113</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2021-08-05T09:11:47Z</dc:date>
    </item>
  </channel>
</rss>

