<?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: Code improvement  SELECT often same source in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594714#M170929</link>
    <description>&lt;P&gt;Isn't that just a case of "update table with values from another table"? If so then SQL code could look like below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  UPDATE GRV_Export_Dummy D
    SET
      d.Supervisor = v.Supervisor__c,
      d.Account = v.Account__c,
      ....
    from GRV_Export_Dummy D, SERVER.VIEW_TABLE V
    WHERE D.Contract = V.VTGONR
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;IF table&amp;nbsp;&lt;CODE class=" language-sas"&gt;SERVER.VIEW_TABLE is big and table GRV_Export_Dummy is not on the same server then a multi step approach would likely perform better. ....but you would need to tell us a bit more what you're dealing with - volumes included.&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Oct 2019 11:58:17 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-10-08T11:58:17Z</dc:date>
    <item>
      <title>Code improvement  SELECT often same source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594704#M170923</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code below works fine so far, but it takes so much time.&lt;/P&gt;&lt;P&gt;It is possible to write this code more comfortable to speed up?&lt;/P&gt;&lt;P&gt;All lines have the same source.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;UPDATE GRV_Export_Dummy D
		SET
			'Supervisor'n = (SELECT 'Supervisor__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Account'n = (SELECT 'Account__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Street'n = (SELECT 'Street__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Country'n = (SELECT 'Country__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Postcode'n = (SELECT 'Postcode__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'City'n = (SELECT 'City__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Contract_start'n = (SELECT 'Contract_start__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Contract_form'n = (SELECT 'Contract_form__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Contract_level'n = (SELECT 'Contract_level__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR)
		WHERE D.Contract IN (SELECT V.VTGONR FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sascha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 11:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594704#M170923</guid>
      <dc:creator>SaschaD</dc:creator>
      <dc:date>2019-10-08T11:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Code improvement  SELECT often same source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594706#M170925</link>
      <description>&lt;P&gt;What is the full code of this updating step ?&lt;/P&gt;
&lt;P&gt;May be it can be rewritten using different procedure ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me that the bottle neck is I/O, network and system overhead, connecting to server.&lt;/P&gt;
&lt;P&gt;Describe the environment you work on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 11:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594706#M170925</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-10-08T11:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Code improvement  SELECT often same source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594713#M170928</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282805"&gt;@SaschaD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my code below works fine so far, but it takes so much time.&lt;/P&gt;
&lt;P&gt;It is possible to write this code more comfortable to speed up?&lt;/P&gt;
&lt;P&gt;All lines have the same source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;UPDATE GRV_Export_Dummy D
		SET
			'Supervisor'n = (SELECT 'Supervisor__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Account'n = (SELECT 'Account__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Street'n = (SELECT 'Street__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Country'n = (SELECT 'Country__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Postcode'n = (SELECT 'Postcode__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'City'n = (SELECT 'City__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Contract_start'n = (SELECT 'Contract_start__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Contract_form'n = (SELECT 'Contract_form__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR),
			'Contract_level'n = (SELECT 'Contract_level__c'n FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR)
		WHERE D.Contract IN (SELECT V.VTGONR FROM SERVER.VIEW_TABLE V WHERE D.Contract = V.VTGONR);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sascha&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use a data step hash object to load the secondary table:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data GRV_Export_Dummy_new;
set GRV_Export_Dummy;
if 0 then set SERVER.VIEW_TABLE (drop=VTGONR); /* sets variable attributes */
if _n_ = 1
then do;
  declare hash lookup(dataset:"SERVER.VIEW_TABLE (rename=(VTGONR=Contract))");
  rc = lookup.definekey("Contract");
  rc = lookup.definedata(
    "Supervisor__c","Account__c","Street__c","Postcode__c","City__c",
    "Contract_start__c","Contract_form__c","Contract_level__c"
  );
  rc = lookup.definedone();
end;
if lookup.find() = 0
then do;
  Supervisor = Supervisor__c;
  Account = Account__c;
  Street = Street__c;
  Country = Country__c;
  Postcode = Postcode__c;
  City = City__c;
  Contract_start = Contract_start__c;
  Contract_form = Contract_form__c;
  Contract_level = Contract_level__c;
end;
drop
  Supervisor__c
  Account__c
  Street__c
  Country__c
  Postcode__c
  City__c
  Contract_start__c
  Contract_form__c
  Contract_level__c
  rc
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 11:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594713#M170928</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-08T11:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Code improvement  SELECT often same source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594714#M170929</link>
      <description>&lt;P&gt;Isn't that just a case of "update table with values from another table"? If so then SQL code could look like below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  UPDATE GRV_Export_Dummy D
    SET
      d.Supervisor = v.Supervisor__c,
      d.Account = v.Account__c,
      ....
    from GRV_Export_Dummy D, SERVER.VIEW_TABLE V
    WHERE D.Contract = V.VTGONR
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;IF table&amp;nbsp;&lt;CODE class=" language-sas"&gt;SERVER.VIEW_TABLE is big and table GRV_Export_Dummy is not on the same server then a multi step approach would likely perform better. ....but you would need to tell us a bit more what you're dealing with - volumes included.&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 11:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/594714#M170929</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-08T11:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Code improvement  SELECT often same source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/595281#M171219</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right, its just an update from another table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SERVER.VIEW_TABLE has 10.000 lines / DUMMY 6.000 lines&lt;/P&gt;&lt;P&gt;Both tables on the the same Server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I tried the Code which you have posted, but I got the error below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;141        proc sql;
142          UPDATE GRV_Export_Dummy D
143            SET
144              D.Supervisor= v.Supervisor__c
                  _
                  73
                  76
ERROR 73-322: Expecting an =.

ERROR 76-322: Syntax error, statement will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  UPDATE GRV_Export_Dummy D
    SET
      D.Supervisor= v.Supervisor__c
    from GRV_Export_Dummy D, &lt;SPAN class="token procnames" style="background-attachment: scroll; background-clip: border-box; background-color: transparent; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; color: #000080; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;SERVER&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="background-attachment: scroll; background-clip: border-box; background-color: transparent; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; color: #999999; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #000000; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; -ms-hyphens: none; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: 0px; word-wrap: normal;"&gt;VIEW_TABLE&lt;/SPAN&gt; V
    WHERE D.Contract= V.VTGONR
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sascha&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 07:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/595281#M171219</guid>
      <dc:creator>SaschaD</dc:creator>
      <dc:date>2019-10-10T07:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Code improvement  SELECT often same source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/595284#M171222</link>
      <description>&lt;P&gt;SQL is not really good at this, because it syntactically needs a sub-select for every variable.&lt;/P&gt;
&lt;P&gt;Since your datasets are really TINY, the hash approach should work, barring any syntax error caused by unavailable example data.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 07:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-improvement-SELECT-often-same-source/m-p/595284#M171222</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-10T07:39:52Z</dc:date>
    </item>
  </channel>
</rss>

