<?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: Delaying to display output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529620#M144734</link>
    <description>&lt;P&gt;Posting the log with option &lt;FONT face="courier new,courier"&gt;fullstimer&lt;/FONT&gt; active could reveal the reason for the delay.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jan 2019 06:21:01 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2019-01-24T06:21:01Z</dc:date>
    <item>
      <title>Delaying to display output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529613#M144732</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I implement a macro to copy a patient details from master-table to sub-table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patient id is a primary key in both table. Now i need to update their Gender,Date-of-birth,First-visit-date of patients by Patient ID.&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;Proc sql;
update sub_table as a 
set sex = (
		select b.sex
		from Master_table b
		where a.P_ID = b.Patient_id and
		)
	where sex is null;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For this query I implement a macro like&amp;nbsp;&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 myUpd1(tbn, vart, varf, from);

proc sql;
update &amp;amp;tbn. a
set &amp;amp;vart. = (select &amp;amp;varf. from &amp;amp;from. where a.P_ID = patient_id)
where &amp;amp;vart. is null;
quit;

%mend myUpd1;

%myUpd1(sub_table, sex, sex, Master_table);
%myUpd1(sub_table, dob, dob, Master_table);
%myUpd1(sub_table, fvdate, firstvisitdate, Master_table);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;%macro :&amp;nbsp;&lt;/P&gt;&lt;P&gt;tbn - subtable&lt;/P&gt;&lt;P&gt;vart - variable to (subtable var)&lt;/P&gt;&lt;P&gt;varf - variable from (Master table var)&lt;/P&gt;&lt;P&gt;from - Master table&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gives a perfect output but for this simple query it takes 15 to 20 minutes to fetch the record from master table.&lt;/P&gt;&lt;P&gt;The sub-table have only 2000 patient ID's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know, What would be the reason behind the delay (Query / any software issue)&lt;/P&gt;&lt;P&gt;While I try this with SQL it implement in seconds but on SAS it take much time. Even though my system is directly connected to the server.&lt;/P&gt;&lt;P&gt;Please let me know the issue,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 04:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529613#M144732</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-01-24T04:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delaying to display output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529620#M144734</link>
      <description>&lt;P&gt;Posting the log with option &lt;FONT face="courier new,courier"&gt;fullstimer&lt;/FONT&gt; active could reveal the reason for the delay.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 06:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529620#M144734</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-01-24T06:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Delaying to display output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529625#M144737</link>
      <description>&lt;P&gt;The method you have chosen runs a sub-query for every row update. This is inherently inefficient. There are much more efficient ways to do table updates in SAS including DATA step MERGEs, UPDATEs or MODIFYs.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 07:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529625#M144737</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-01-24T07:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Delaying to display output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529637#M144745</link>
      <description>&lt;P&gt;Hi Sathis_jammy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yout problem is the 6000 sub-selects needed to update your 2000 records in the sub-table. You could optimize by updating all variables at the same time, like&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;vart1, &amp;amp;vart2, &amp;amp;vart3 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;varf1, &amp;amp;varf2, &amp;amp;varf3 &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;P_ID &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; patient_id&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;But a&amp;nbsp;join would be much more efficient, You cannot join "in place", but joining to a work table and then replacing the subtable will hardly be felt with such a small subtable. I suggest something like (not tested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro myupd1(sub_table, master_table);
	proc sql;
		* create updated work subtable;
		create table work.new_sub_table as
			select
				&amp;amp;sub_table.P_ID,
				&amp;amp;sub_table.other_variable1,
				&amp;amp;sub_table.other_variable2,
				...
				&amp;amp;master_table.sex,
				&amp;amp;master_table.dob,
				&amp;amp;master_table.firstvisitdate as fvdate
			from &amp;amp;sub_table
			left join &amp;amp;master_table
			on &amp;amp;sub_table.P_ID = &amp;amp;master_table.P_ID;
	quit;

	* Write back to permanent subtable;
	%if &amp;amp;sqlrc = 0 %then %do;
		create table &amp;amp;sub_table as
			select * 
			from work.new_sub_table;
		quit;
	%end;
%mend;
%myUpd1(sub_table, Master_table);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 08:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delaying-to-display-output/m-p/529637#M144745</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-01-24T08:59:08Z</dc:date>
    </item>
  </channel>
</rss>

