<?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: how to insert a new colomn into dataset use proc sql? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107857#M30054</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza and Haikuo both use the ALTER statement. I believe that this implicitly causes the creation of a new table to replace the old one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This can be demonstrated by toggling the REPLACE system option to NOREPLACE before invoking ALTER.&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;Mike.Davis wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you all.&lt;/P&gt;
&lt;P&gt;LinLin's method and Reeza and Haikuo's methods all works,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;LinLin's method create a new dataset but the other not, except this what is the other main difference?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2012 21:07:57 GMT</pubDate>
    <dc:creator>Howles</dc:creator>
    <dc:date>2012-06-01T21:07:57Z</dc:date>
    <item>
      <title>how to insert a new column into dataset use proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107852#M30049</link>
      <description>&lt;P&gt;How do you insert/update a new column into dataset using PROC SQL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 16:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107852#M30049</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2016-10-31T16:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a new colomn into dataset use proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107853#M30050</link>
      <description>&lt;P&gt;It depends.&lt;/P&gt;
&lt;P&gt;you can use JOIN to get the column from another dataset or use the code below to insert an empty column:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id age;
cards;
1 20
2 30
;
proc sql;
create table want
&amp;nbsp;&amp;nbsp; as select *, ' ' format=$8. as new_col from have;
quit;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to add a new column you can &lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/69049/HTML/default/viewer.htm#n1ckvfae6xf2tyn1nrivm6egpr8b.htm" target="_self"&gt;use SQL to alter the table as well&lt;/A&gt; - i.e. add a column called grade to the class table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
run;
&amp;nbsp;&amp;nbsp;
proc sql;
&amp;nbsp;&amp;nbsp; alter table class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add grade num label='School Grade' format=6.2;
quit;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 16:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107853#M30050</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2016-10-31T16:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a new colomn into dataset use proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107854#M30051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need to add a new column you can use SQL to alter the table as well&lt;/P&gt;&lt;P&gt;IE add a column called grade to the class table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; alter table class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add grade num label='School Grade' format=6.2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 20:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107854#M30051</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-05-08T20:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a new colomn into dataset use proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107855#M30052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you are asking to add (insert) columns to the existing table, take a look at this page:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002294523.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002294523.htm"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002294523.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P id="bookpage"&gt;&lt;/P&gt;&lt;DIV class="sgml"&gt;&lt;TABLE cellpadding="4" cellspacing="2"&gt;&lt;TBODY&gt;&lt;TR valign="top"&gt;&lt;TD&gt;&lt;SPAN class="strong"&gt;PROC SQL&lt;/SPAN&gt; &amp;lt;&lt;SPAN class="emph"&gt;option(s)&lt;/SPAN&gt;&amp;gt;; &lt;TABLE cellpadding="2" cellspacing="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="24"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN class="strong"&gt;ALTER TABLE&lt;/SPAN&gt; &lt;SPAN class="emph"&gt;table-name&lt;/SPAN&gt; &lt;TABLE cellpadding="2" cellspacing="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="24"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE cellpadding="2" cellspacing="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="24"&gt;&lt;/TD&gt;&lt;TD&gt;&amp;lt;&lt;SPAN class="strong"&gt;ADD&lt;/SPAN&gt; column-definition&amp;lt;, ... column-definition&amp;gt;&amp;gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 20:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107855#M30052</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-05-08T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a new colomn into dataset use proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107856#M30053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you all.&lt;/P&gt;&lt;P&gt;LinLin's method and Reeza and Haikuo's methods all works,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LinLin's method create a new dataset but the other not, except this what is the other main difference?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2012 13:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107856#M30053</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-05-09T13:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a new colomn into dataset use proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107857#M30054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza and Haikuo both use the ALTER statement. I believe that this implicitly causes the creation of a new table to replace the old one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This can be demonstrated by toggling the REPLACE system option to NOREPLACE before invoking ALTER.&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;Mike.Davis wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you all.&lt;/P&gt;
&lt;P&gt;LinLin's method and Reeza and Haikuo's methods all works,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;LinLin's method create a new dataset but the other not, except this what is the other main difference?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 21:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-insert-a-new-column-into-dataset-use-proc-sql/m-p/107857#M30054</guid>
      <dc:creator>Howles</dc:creator>
      <dc:date>2012-06-01T21:07:57Z</dc:date>
    </item>
  </channel>
</rss>

