<?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 Add SAS Table Column with Default Value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191848#M48237</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What command can I use to create a column in a SAS table and initialize it to default value 'N' ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alter table LIB1.TABLE1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADD FLAG char(1) format = $1. &lt;SPAN style="color: #ff0000;"&gt;DEFAULT 'N'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Dec 2014 11:59:48 GMT</pubDate>
    <dc:creator>DavidCaliman</dc:creator>
    <dc:date>2014-12-01T11:59:48Z</dc:date>
    <item>
      <title>Add SAS Table Column with Default Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191848#M48237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What command can I use to create a column in a SAS table and initialize it to default value 'N' ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alter table LIB1.TABLE1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADD FLAG char(1) format = $1. &lt;SPAN style="color: #ff0000;"&gt;DEFAULT 'N'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 11:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191848#M48237</guid>
      <dc:creator>DavidCaliman</dc:creator>
      <dc:date>2014-12-01T11:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add SAS Table Column with Default Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191849#M48238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alter table LIB1.TABLE1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADD FLAG char format = $1.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; update LIB1.TABLE1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set FLAG='N';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 13:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191849#M48238</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-12-01T13:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add SAS Table Column with Default Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191850#M48239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to add, as that is a flag you may run into issues if you default a value in rather than conditionally.&amp;nbsp; I always have a three part case, Y if true, N if not true, else value (could be default or value).&amp;nbsp; Otherwise defaulting in N might indicate something is not true, when missing for instance.&amp;nbsp; E.g.&lt;/P&gt;&lt;P&gt;set FLAG=case&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when exists(select distinct A from B where A=5) then "Y"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when exists(select distinct A from B where A=4) then "N"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else "" end&lt;/P&gt;&lt;P&gt;If you default then A=1,2,3 would also give N, which could be misleading i.e. indicates they have a record=4.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 14:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191850#M48239</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-12-01T14:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add SAS Table Column with Default Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191851#M48240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I couldn't find a way to add a true default constraint (i.e. one that creates a value on insertion).&amp;nbsp; Looks like you'll need to insert a value or it will be missing unless you run the update statement after each insert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 15:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191851#M48240</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2014-12-01T15:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Add SAS Table Column with Default Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191852#M48241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As &lt;A _jive_internal="true" href="https://communities.sas.com/people/DBailey"&gt;https://communities.sas.com/people/DBailey&lt;/A&gt; mentions, there is no support i SAS for default constraints.&lt;/P&gt;&lt;P&gt;What you can do is to use CHECK or NOT NULL constraints to enforce the inserting process' to use (correct) values.&lt;/P&gt;&lt;P&gt;How will this/these tables be maintained?&lt;/P&gt;&lt;P&gt;If this is critical, and the value is hard to update/insert afterwards, consider using an external data source that supports default constraints.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 16:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191852#M48241</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-12-01T16:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Add SAS Table Column with Default Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191853#M48242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the only default that SAS defaults is missing.&lt;/P&gt;&lt;P&gt;If you insist on seeing N&amp;nbsp;&amp;nbsp; then just apply a user format that supplies an N for missing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 17:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-SAS-Table-Column-with-Default-Value/m-p/191853#M48242</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-12-01T17:25:39Z</dc:date>
    </item>
  </channel>
</rss>

