<?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 simplify the codes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492349#M129365</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running following codes, which may be need to spend total 2.5 days. Could you please give me some suggestion to simplify the codes, thereby saving times?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro  base_of_cit;
   %local y;
   %do y=2005 %to 2015;

   %local m;
   %do m=1 %to 12;

PROC SQL;
   CREATE TABLE Step2.base_of_cit&amp;amp;y.&amp;amp;m AS
     SELECT
      DISTINCT
       Docdb_family_id AS docdb_family_id_base, 
       co.psn_name
     FROM 
       Step2.year&amp;amp;y AS ap
       JOIN Pat_ori.Personapplication AS pe ON ap.appln_id = pe.appln_id
       JOIN Pat_ori.Companies AS co ON pe.person_id = co.person_id
       JOIN Pat_ori.Publicationsnew AS pu ON ap.appln_id = pu.appln_id
       JOIN Pat_ori.Citations AS ci ON pu.pat_publn_id = ci.pat_publn_id
     WHERE 
       pe.applt_seq_nr &amp;gt; 0 /* to force the query to look only at persons who are applicants*/
       AND ap.month = &amp;amp;m
       AND ci.cited_pat_publn_id &amp;gt; 0 /* to guarantee that all cited publications have been included in the sample */
     GROUP BY psn_name
     ORDER BY psn_name
;
QUIT;

PROC SQL;
   CREATE TABLE Step3.No_of_cit&amp;amp;y.&amp;amp;m AS
     SELECT
      t_base.psn_name,
      COUNT(DISTINCT t_do.docdb_family_id) AS No_of_citation
     FROM 
       Step2.base_of_cit&amp;amp;y.&amp;amp;m AS t_base
       JOIN Pat_ori.Applicationsnew AS t_ap1 ON t_ap1.docdb_family_id = t_base.docdb_family_id_base /* to set the moving window */
       JOIN Pat_ori.Docdbfamiliescitations AS t_do ON t_do.cited_docdb_family_id=t_base.docdb_family_id_base
       JOIN Pat_ori.Applicationsnew AS t_ap2 ON t_ap2.docdb_family_id=t_do.docdb_family_id
       JOIN Pat_ori.Publicationsnew AS t_pu ON t_pu.appln_id=t_ap2.appln_id
     WHERE
       YEAR(t_ap1.earliest_publn_date) NE 9999
       AND YEAR(t_pu.publn_date) NE 9999
       AND t_pu.publn_date &amp;lt;= intnx('year',t_ap1.earliest_publn_date,6) /* a 6-year moving window starting at the earliest publication date of a patent family */
     GROUP BY t_base.psn_name
     ORDER BY t_base.psn_name
;
QUIT;

%end;
%end; 
%mend base_of_cit;   

%base_of_cit;
 
 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Sep 2018 15:52:33 GMT</pubDate>
    <dc:creator>France</dc:creator>
    <dc:date>2018-09-04T15:52:33Z</dc:date>
    <item>
      <title>simplify the codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492349#M129365</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running following codes, which may be need to spend total 2.5 days. Could you please give me some suggestion to simplify the codes, thereby saving times?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro  base_of_cit;
   %local y;
   %do y=2005 %to 2015;

   %local m;
   %do m=1 %to 12;

PROC SQL;
   CREATE TABLE Step2.base_of_cit&amp;amp;y.&amp;amp;m AS
     SELECT
      DISTINCT
       Docdb_family_id AS docdb_family_id_base, 
       co.psn_name
     FROM 
       Step2.year&amp;amp;y AS ap
       JOIN Pat_ori.Personapplication AS pe ON ap.appln_id = pe.appln_id
       JOIN Pat_ori.Companies AS co ON pe.person_id = co.person_id
       JOIN Pat_ori.Publicationsnew AS pu ON ap.appln_id = pu.appln_id
       JOIN Pat_ori.Citations AS ci ON pu.pat_publn_id = ci.pat_publn_id
     WHERE 
       pe.applt_seq_nr &amp;gt; 0 /* to force the query to look only at persons who are applicants*/
       AND ap.month = &amp;amp;m
       AND ci.cited_pat_publn_id &amp;gt; 0 /* to guarantee that all cited publications have been included in the sample */
     GROUP BY psn_name
     ORDER BY psn_name
;
QUIT;

PROC SQL;
   CREATE TABLE Step3.No_of_cit&amp;amp;y.&amp;amp;m AS
     SELECT
      t_base.psn_name,
      COUNT(DISTINCT t_do.docdb_family_id) AS No_of_citation
     FROM 
       Step2.base_of_cit&amp;amp;y.&amp;amp;m AS t_base
       JOIN Pat_ori.Applicationsnew AS t_ap1 ON t_ap1.docdb_family_id = t_base.docdb_family_id_base /* to set the moving window */
       JOIN Pat_ori.Docdbfamiliescitations AS t_do ON t_do.cited_docdb_family_id=t_base.docdb_family_id_base
       JOIN Pat_ori.Applicationsnew AS t_ap2 ON t_ap2.docdb_family_id=t_do.docdb_family_id
       JOIN Pat_ori.Publicationsnew AS t_pu ON t_pu.appln_id=t_ap2.appln_id
     WHERE
       YEAR(t_ap1.earliest_publn_date) NE 9999
       AND YEAR(t_pu.publn_date) NE 9999
       AND t_pu.publn_date &amp;lt;= intnx('year',t_ap1.earliest_publn_date,6) /* a 6-year moving window starting at the earliest publication date of a patent family */
     GROUP BY t_base.psn_name
     ORDER BY t_base.psn_name
;
QUIT;

%end;
%end; 
%mend base_of_cit;   

%base_of_cit;
 
 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 15:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492349#M129365</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-04T15:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: simplify the codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492357#M129371</link>
      <description>How big is each data set? Can you precombine them in a view and avoid the macro loop? That would be the fastest way to speed this up. And I notice multiple libraries. Are they all on the same DB or machine or are some on the server and some local on your machine or a different server?&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Sep 2018 16:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492357#M129371</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-04T16:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: simplify the codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492499#M129423</link>
      <description>&lt;P&gt;Dear Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help. I will precomine them and then count the number of data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 23:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simplify-the-codes/m-p/492499#M129423</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-04T23:11:09Z</dc:date>
    </item>
  </channel>
</rss>

