<?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: Update an existing column throught join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824684#M325688</link>
    <description>&lt;P&gt;If a client (who hires me because they're less expert than me) wants to tell &lt;U&gt;me&lt;/U&gt; which method to use to achieve the goal, &lt;U&gt;I tell them&lt;/U&gt; (in very polite words) that they're idiots and should not interfere with the doings of grown-ups.&lt;/P&gt;
&lt;P&gt;All that a client may tell you without disqualifying them as imbeciles is&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;we have ... (the data they start with)&lt;/LI&gt;
&lt;LI&gt;we want ... (the result which should be obtained)&lt;/LI&gt;
&lt;LI&gt;we can provide ... (the extent of their SAS license, the available storage, memory etc)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;How you get from 1 to 2 using 3 is up to you, the expert.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2022 14:57:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-07-21T14:57:50Z</dc:date>
    <item>
      <title>Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824301#M325523</link>
      <description>&lt;P&gt;Good morning everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would find a way to insert new values ( came out from a join) in a column altready existing in one step (I know that I can do this with two steps).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have altready add the new column with alter table step:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;alter table Mis2dm._3006_AG_E_DM_T031_INDOTHX&lt;BR /&gt;add E_T031_X0010&amp;nbsp; char(250);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would update values of E_T031_X0010 column throught this join :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table AG_E_DM_T031_INDOTHX_PROVA as&lt;BR /&gt;select a.*,&lt;BR /&gt;case when E_T031_C0010=E_DOMINIO then E_DESCRIZIONE&lt;BR /&gt;else E_T031_C0010 end as E_T031_X0010&lt;BR /&gt;from mis2dm.AG_E_DM_T031_INDOTHX a&lt;BR /&gt;left join DOMINI_LDR_FIX b&lt;BR /&gt;on a.E_PU_08910=b.E_PU_08910 and a.E_T031_C0010=b.E_DOMINIO ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log:&lt;/P&gt;&lt;PRE&gt;1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Aggiunta campi con sigla X';
4          %LET _CLIENTPROCESSFLOWNAME='Flusso dei processi';
5          %LET _CLIENTPROJECTPATH='C:\Users\AntonioCiccaglione\Desktop\Iccrea\Implementazione colonne X e aggiunta descrizione.egp'
5        ! ;
6          %LET _CLIENTPROJECTPATHHOST='LAPTOP-5ML4ES7K';
7          %LET _CLIENTPROJECTNAME='Implementazione colonne X e aggiunta descrizione.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=SVG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         %macro HTML5AccessibleGraphSupported;
15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) &amp;gt;= 0 %then ACCESSIBLE_GRAPH;
16         %mend;
17         FILENAME EGHTML TEMP;
18         ODS HTML5(ID=EGHTML) FILE=EGHTML
19             OPTIONS(BITMAP_MODE='INLINE')
20             %HTML5AccessibleGraphSupported
21             ENCODING='utf-8'
22             STYLE=HtmlBlue
23             NOGTITLE
24             NOGFOOTNOTE
25             GPATH=&amp;amp;sasworklocation
26         ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27         
28         proc sql;
29         create table AG_E_DM_T031_INDOTHX_PROVA as
30         select a.*,
31         case when E_T031_C0010=E_DOMINIO then E_DESCRIZIONE
32         else E_T031_C0010 end as E_T031_X0010
33         from mis2dm.AG_E_DM_T031_INDOTHX  a
34         left join DOMINI_LDR_FIX  b
35         on a.E_PU_08910=b.E_PU_08910 and a.E_T031_C0010=b.E_DOMINIO ;
WARNING: Variable E_T031_X0010 already exists on file WORK.AG_E_DM_T031_INDOTHX_PROVA.
NOTE: Table WORK.AG_E_DM_T031_INDOTHX_PROVA created, with 34 rows and 59 columns.

36         
37         quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.02 seconds
      memory              15025.59k
      OS Memory           34392.00k
      Timestamp           20/07/2022 08:53:41 m.
      Step Count                        21  Switch Count  2
      Page Faults                       0
      Page Reclaims                     1059
      Page Swaps                        0
      Voluntary Context Switches        137
      Involuntary Context Switches      1
      Block Input Operations            0
      Block Output Operations           2080&lt;/PRE&gt;&lt;P&gt;Many Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 08:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824301#M325523</guid>
      <dc:creator>Anto180788</dc:creator>
      <dc:date>2022-07-20T08:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824309#M325527</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; already gave the answer in the original thread: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Help-to-fill-this-column/m-p/824113" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Help-to-fill-this-column/m-p/824113&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 09:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824309#M325527</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-07-20T09:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824316#M325531</link>
      <description>&lt;P&gt;Since you create a dataset in WORK, the SQL UPDATE statement cannot be used (which is the proper way to update existing columns in SQL).&lt;/P&gt;
&lt;P&gt;You can add the LENGTH=250 specification in the SQL I provided in your other thread, but you CANNOT update an existing column in the way you tried here. It simply is not possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be honest, I would not use SQL for this anyway. I'd either run a MERGE in a data step, or (even better) use a hash object:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data AG_E_DM_T031_INDOTHX_PROVA;
set mis2dm.AG_E_DM_T031_INDOTHX;
if _n_ =1
then do;
  declare hash b (dataset:"DOMINI_LDR_FIX (rename=(E_DOMINIO=E_T031_C0010 E_DESCRIZIONE=E_T031_X0010))");
  b.definekey("E_PU_08910","E_T031_C0010");
  b.definedata("E_DESCRIZIONE");
  b.definedone();
end;
rc = b.find();
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 09:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824316#M325531</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-20T09:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824336#M325542</link>
      <description>HI andreas,&lt;BR /&gt;Kurt said to drop the column in order to add the new column with values.&lt;BR /&gt;My objective is to update a column, in order to keep its position in the table.&lt;BR /&gt;Dropping the new column and adding new one by join, it will result at the end of table.&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824336#M325542</guid>
      <dc:creator>Anto180788</dc:creator>
      <dc:date>2022-07-20T12:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824339#M325545</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399935"&gt;@Anto180788&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;HI andreas,&lt;BR /&gt;Kurt said to drop the column in order to add the new column with values.&lt;BR /&gt;My objective is to update a column, in order to keep its position in the table.&lt;BR /&gt;Dropping the new column and adding new one by join, it will result at the end of table.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is a complete non-argument, for several reasons.&lt;/P&gt;
&lt;P&gt;First, ALTER TABLE (as is used in your example where this is shown) will also add the column at the end of the observations, so dropping and re-adding it will not change anything.&lt;/P&gt;
&lt;P&gt;Second, variables are always addressed by &lt;U&gt;name&lt;/U&gt;, not by position, so the position within observations is irrelevant.&lt;/P&gt;
&lt;P&gt;Third, using a comprehensive list in the SQL SELECT allows you to specify the position of &lt;U&gt;every&lt;/U&gt; variable, if that is of importance to you.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824339#M325545</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-20T12:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824340#M325546</link>
      <description>&lt;P&gt;Thank you so much Kurt.&lt;BR /&gt;1) I dont'know hash object yet, but I know you should be very carefully to use it.&lt;/P&gt;&lt;P&gt;If I would see the output of your code, Should I just run it?&lt;BR /&gt;&lt;BR /&gt;2) According to you, given that i can't update by join, how can I update the column in 2 step.&lt;BR /&gt;I think I have to create a temporary table to store the new column and then update the existing column by data step.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824340#M325546</guid>
      <dc:creator>Anto180788</dc:creator>
      <dc:date>2022-07-20T12:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824353#M325555</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399935"&gt;@Anto180788&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much Kurt.&lt;BR /&gt;1) I dont'know hash object yet, but I know you should be very carefully to use it.&lt;/P&gt;
&lt;P&gt;If I would see the output of your code, Should I just run it?&lt;BR /&gt;&lt;BR /&gt;2) According to you, given that i can't update by join, how can I update the column in 2 step.&lt;BR /&gt;I think I have to create a temporary table to store the new column and then update the existing column by data step.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have to be careful with every bit of code you do. That's a given, don't work with tools you don't know how to handle.&lt;/P&gt;
&lt;P&gt;I have already given you the answer for 2): don't use the asterisk, create the variable anew with the same attributes set in the (unnecessary)&amp;nbsp; ALTER TABLE statement.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 13:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824353#M325555</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-20T13:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824356#M325556</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399935"&gt;@Anto180788&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Thank you so much Kurt.&lt;BR /&gt;1) I dont'know hash object yet, but I know you should be very carefully to use it.&lt;/P&gt;&lt;P&gt;If I would see the output of your code, Should I just run it?&lt;BR /&gt;&lt;BR /&gt;2) According to you, given that i can't update by join, how can I update the column in 2 step.&lt;BR /&gt;I think I have to create a temporary table to store the new column and then update the existing column by data step.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You have to be careful with every bit of code you do. That's a given, don't work with tools you don't know how to handle.&lt;/P&gt;&lt;P&gt;I have already given you the answer for 2): don't use the asterisk, create the variable anew with the same attributes set in the (unnecessary)&amp;nbsp; ALTER TABLE statement.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;1) I don't think that is only a problem to know hash object in order to decide if you can or not work on a task.&lt;/P&gt;&lt;P&gt;If your client (or somthing else) say that want new values only updating an existing column, you can't say only no.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) So i have to remove alter table and create new one while run a join. In this way, the new column will be in the of table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 13:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824356#M325556</guid>
      <dc:creator>Anto180788</dc:creator>
      <dc:date>2022-07-20T13:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824380#M325577</link>
      <description>&lt;P&gt;The new variable will be where you place it in the SQL SELECT; if you put it first, it will be the first variable in an observation.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 15:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824380#M325577</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-20T15:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824589#M325654</link>
      <description>Thank you very much Kurt.&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Jul 2022 11:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824589#M325654</guid>
      <dc:creator>Anto180788</dc:creator>
      <dc:date>2022-07-21T11:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Update an existing column throught join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824684#M325688</link>
      <description>&lt;P&gt;If a client (who hires me because they're less expert than me) wants to tell &lt;U&gt;me&lt;/U&gt; which method to use to achieve the goal, &lt;U&gt;I tell them&lt;/U&gt; (in very polite words) that they're idiots and should not interfere with the doings of grown-ups.&lt;/P&gt;
&lt;P&gt;All that a client may tell you without disqualifying them as imbeciles is&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;we have ... (the data they start with)&lt;/LI&gt;
&lt;LI&gt;we want ... (the result which should be obtained)&lt;/LI&gt;
&lt;LI&gt;we can provide ... (the extent of their SAS license, the available storage, memory etc)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;How you get from 1 to 2 using 3 is up to you, the expert.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 14:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-an-existing-column-throught-join/m-p/824684#M325688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-21T14:57:50Z</dc:date>
    </item>
  </channel>
</rss>

