<?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: Primary key in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456423#M115603</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000247691.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000247691.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Primary keys can speed up merges/joins - which as a database (RDBMs) does a lot it will be used a lot.&amp;nbsp; Most SAS programming is stepwise, so less joining.&amp;nbsp; Never actually used a key in SAS in years.&amp;nbsp; This is just an opinion though, if you use proc sql a lot, connect to databases etc. then you will need it more I would imagine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Apr 2018 08:19:02 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-04-23T08:19:02Z</dc:date>
    <item>
      <title>Primary key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456421#M115602</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I know that there is a way to create a primary key to a table using proc sql.&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;Alter table&amp;nbsp;aaa&lt;BR /&gt;Add primary key(ID,month);&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to add a primary key to a data set by using sas data set and not proc sql?&lt;/P&gt;&lt;P&gt;What is the advantage of adding a primary key to a table?&lt;/P&gt;&lt;P&gt;Usually when I see SAS programs I don't see that people adding primary key to data sets.&lt;/P&gt;&lt;P&gt;But in sql server I usually see that people add primary key to tables.&lt;/P&gt;&lt;P&gt;Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;R&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 08:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456421#M115602</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-04-23T08:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Primary key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456423#M115603</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000247691.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000247691.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Primary keys can speed up merges/joins - which as a database (RDBMs) does a lot it will be used a lot.&amp;nbsp; Most SAS programming is stepwise, so less joining.&amp;nbsp; Never actually used a key in SAS in years.&amp;nbsp; This is just an opinion though, if you use proc sql a lot, connect to databases etc. then you will need it more I would imagine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 08:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456423#M115603</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-23T08:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Primary key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456424#M115604</link>
      <description>&lt;P&gt;SAS does not have the concept of primary keys. But you can add a unique index, which amounts to about the same:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create unique index prim_key
  on aaa(ID,month);
quit;  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The only difference being that unique keys do not require the columns to be NOT NULL. You will have to add constraints for that separately, if you want it.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 08:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456424#M115604</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-04-23T08:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Primary key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456427#M115607</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The info under below link might give you a lot of the information you're after.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n06cy7dznbx6gen1q9mat8de6rdq.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&amp;nbsp;" target="_blank"&gt;http://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n06cy7dznbx6gen1q9mat8de6rdq.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 09:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456427#M115607</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-04-23T09:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Primary key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456470#M115625</link>
      <description>&lt;P&gt;Actually, SAS has PK/FK constraints for Base data sets:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Primary-key/m-p/456421" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Primary-key/m-p/456421&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create in data step - no, PROC DATASETS, SQL and SCL (!) is the only ways to define them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why use them: apart from potential performance gains during join, they obviously cater for referential integrity - helps you maintaining your data model intact.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not so often in SAS - that's perhaps because RDBMS and SAS often has different use cases, whereas SAS is more flexible and users have more "power". But if you wish to build a governed solution with structured ETL and so forth, PK/FK could definitely be part of the design even in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 11:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Primary-key/m-p/456470#M115625</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-04-23T11:52:15Z</dc:date>
    </item>
  </channel>
</rss>

