<?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: updating  a table in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339287#M63138</link>
    <description>&lt;P&gt;Hi Tal,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a rule you cannot add columns to a table without rewriting it. What we see here is actually a case of poor data modelling. It is generally way more useful to have a model transposed from what you show:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id date value&lt;/P&gt;
&lt;P&gt;10 1/1/2017 123&lt;/P&gt;
&lt;P&gt;11 1/1/2017 456&lt;/P&gt;
&lt;P&gt;10 2/1/2017 null&lt;/P&gt;
&lt;P&gt;etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your updates would simply be additional rows to the table or updates of the value column, which is easy and efficient. Your table design will not have to change with every update and analysis would be so muych easier as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 16:03:37 GMT</pubDate>
    <dc:creator>jklaverstijn</dc:creator>
    <dc:date>2017-03-08T16:03:37Z</dc:date>
    <item>
      <title>updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339283#M63137</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;
&lt;P&gt;We have a&amp;nbsp; table (table_a) on&amp;nbsp;sql server such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;1/1/2017&amp;nbsp; 2/1/2017&amp;nbsp;&amp;nbsp; 3/1/2017&amp;nbsp; 4/1/2017&lt;/P&gt;
&lt;P&gt;---------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;10&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 555&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null&lt;/P&gt;
&lt;P&gt;11&amp;nbsp;&amp;nbsp; 456&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 666&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;meaning that table has not been updated with this month data yet which i have as a&amp;nbsp; dataset:(table_b)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3/1/2017&lt;/P&gt;
&lt;P&gt;--------------------&lt;/P&gt;
&lt;P&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 189&lt;/P&gt;
&lt;P&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the best way to update table_a?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i am thinking of&lt;/P&gt;
&lt;P&gt;create table_a as select *from table_a,table_b where a.oid=b.oid;quit;&lt;/P&gt;
&lt;P&gt;but that is kinda overwriting a table and&amp;nbsp; dont know how to do this using "update table_a" as i am not adding rows to table_a but actually adding columns&lt;/P&gt;
&lt;P&gt;I am doing this in SAS and the dataset i have has about 200 records&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any one please?&lt;/P&gt;
&lt;P&gt;thx&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339283#M63137</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2017-03-08T16:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339287#M63138</link>
      <description>&lt;P&gt;Hi Tal,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a rule you cannot add columns to a table without rewriting it. What we see here is actually a case of poor data modelling. It is generally way more useful to have a model transposed from what you show:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id date value&lt;/P&gt;
&lt;P&gt;10 1/1/2017 123&lt;/P&gt;
&lt;P&gt;11 1/1/2017 456&lt;/P&gt;
&lt;P&gt;10 2/1/2017 null&lt;/P&gt;
&lt;P&gt;etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your updates would simply be additional rows to the table or updates of the value column, which is easy and efficient. Your table design will not have to change with every update and analysis would be so muych easier as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339287#M63138</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-08T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339290#M63139</link>
      <description>&lt;P&gt;thanks Jan,&lt;/P&gt;
&lt;P&gt;the sql server table has way too many fields actually so not sure how&amp;nbsp; transposing with work but overwriting it wont hurt&amp;nbsp; right?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339290#M63139</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2017-03-08T16:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339301#M63140</link>
      <description>&lt;P&gt;If it hurts or not is not up to me to decide. It is not efficient as all data will have to be rewritten even if it diodn't change. Dependiong on the number of rows and columns that may be or over time become a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And rewriting is not the only issue I pointed at. Depending on what operations (reporting, analysis) are done on the table, the changing structure may be an issue. It means the program will have to change after every update. Also as some business data are actually stored inside column names instead of column values you will always have to do some stuntwork before making sense of it, subsetting time periods etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS can help you transpose the table and make your life a lot easier. There is a blog post on this kind of modelling problem. I will link to it when I find it. The general consensus about your current approach is: don't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UPDATE: Found the post: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/3-common-messy-data-problems-and-how-to-tidy-them-in-SAS/ta-p/272165" target="_self"&gt;Common messy data problems and how to tidy them in SAS. &lt;/A&gt;Your issue is Messy Data Scenario 1 – Dimension values stored as column names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339301#M63140</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-08T16:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339305#M63142</link>
      <description>&lt;P&gt;i am not changing the structure of the&amp;nbsp; table. All fields exist already&amp;nbsp;I am only updating columns with null values but if&amp;nbsp; you can find those links would be appeciated.&lt;/P&gt;
&lt;P&gt;thx&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339305#M63142</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2017-03-08T16:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339307#M63143</link>
      <description>Oke I see. But I stick to my advice: don't do this. I added the link; have a look.</description>
      <pubDate>Wed, 08 Mar 2017 16:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339307#M63143</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-08T16:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339318#M63146</link>
      <description>&lt;P&gt;thanks&amp;nbsp; i will take&amp;nbsp; a look&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339318#M63146</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2017-03-08T16:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339422#M63157</link>
      <description>&lt;P&gt;Am I right: you want to update table_a by trunsactions in data_b ?&lt;/P&gt;
&lt;P&gt;If you have tose datsets already in SAs you can do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data_a;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;update&lt;/STRONG&gt; data_a data_b;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that is, assuming &lt;STRONG&gt;each daily data has its own variable.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You haven't show the variable names. The header &lt;STRONG&gt;3/1/2017&lt;/STRONG&gt; is &lt;U&gt;not a valid&lt;/U&gt; sas name.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 20:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339422#M63157</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-08T20:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: updating  a table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339840#M63190</link>
      <description>&lt;P&gt;thanks Shmuel your approach works&amp;nbsp; perfectly&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 01:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/updating-a-table/m-p/339840#M63190</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2017-03-10T01:02:05Z</dc:date>
    </item>
  </channel>
</rss>

