<?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 create Surrogate Key and SCD type 2 in SAS Studio by code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/698066#M213445</link>
    <description>&lt;P&gt;I'm having data like this,&lt;/P&gt;&lt;P&gt;Subject_ID&amp;nbsp; &amp;nbsp;Test_Name&amp;nbsp; Start_Date End_Date&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XYZ&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XYZ&lt;/P&gt;&lt;P&gt;and respective dates for those ID's, I want to create one more Variable ROWID for above dataset which will have sequential count for every&amp;nbsp;Subject_ID&amp;nbsp; and Test_Name. It should be depends on both these variables. Like an example: If there is a first test ABC for subject 123 then ROWID will '1' and for next test ABC for same subject 123 ROWID will '2'&amp;nbsp; but if Test is ABC and subject is 124 then it should start from '1'.&lt;/P&gt;&lt;P&gt;Output like below:&lt;/P&gt;&lt;P&gt;ROWID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2020 03:59:58 GMT</pubDate>
    <dc:creator>akshay3</dc:creator>
    <dc:date>2020-11-11T03:59:58Z</dc:date>
    <item>
      <title>How to create Surrogate Key and SCD type 2 in SAS Studio by code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/697865#M213358</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to create Surrogate Key and want to apply slowly changing dimension to a dataset from SAS studio by using SAS coding.&lt;/P&gt;&lt;P&gt;Can anyone give me the outline/concept How can we do this by code?&lt;/P&gt;&lt;P&gt;I have a Test dataset and observations from that will update on regular basis. I want to create a ID which will auto increment for every new test given by a specific participant. and ID will start from "1" and it will automatically increment if there is another test given by the same participant at different time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 11:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/697865#M213358</guid>
      <dc:creator>akshay3</dc:creator>
      <dc:date>2020-11-10T11:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Surrogate Key and SCD type 2 in SAS Studio by code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/697915#M213384</link>
      <description>&lt;P&gt;This is somewhat a complex task, given your detail requirements.&lt;/P&gt;
&lt;P&gt;This is implemented in Data Integration Studio, end there's a reason why there exist ETL tools, so we don't have to reinvent the wheel.&lt;/P&gt;
&lt;P&gt;If you don't know how to start, the risk is that you can't complete the task by yourself.&lt;/P&gt;
&lt;P&gt;So I suggest that you try to involve someone&amp;nbsp; directly in this job.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/697915#M213384</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2020-11-10T16:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Surrogate Key and SCD type 2 in SAS Studio by code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/697928#M213386</link>
      <description>&lt;P&gt;Could you give us an example for your dataset, how you want the surrogate key to look for that data, and what you get when the update happens?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/697928#M213386</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-10T16:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Surrogate Key and SCD type 2 in SAS Studio by code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/698066#M213445</link>
      <description>&lt;P&gt;I'm having data like this,&lt;/P&gt;&lt;P&gt;Subject_ID&amp;nbsp; &amp;nbsp;Test_Name&amp;nbsp; Start_Date End_Date&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XYZ&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XYZ&lt;/P&gt;&lt;P&gt;and respective dates for those ID's, I want to create one more Variable ROWID for above dataset which will have sequential count for every&amp;nbsp;Subject_ID&amp;nbsp; and Test_Name. It should be depends on both these variables. Like an example: If there is a first test ABC for subject 123 then ROWID will '1' and for next test ABC for same subject 123 ROWID will '2'&amp;nbsp; but if Test is ABC and subject is 124 then it should start from '1'.&lt;/P&gt;&lt;P&gt;Output like below:&lt;/P&gt;&lt;P&gt;ROWID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 03:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/698066#M213445</guid>
      <dc:creator>akshay3</dc:creator>
      <dc:date>2020-11-11T03:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Surrogate Key and SCD type 2 in SAS Studio by code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/698076#M213451</link>
      <description>&lt;P&gt;Now that's simple:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by subject_id test_name start_date;
run;

data want;
set have;
by subject_id test_name;
if first.test_name
then rowid =1;
else rowid + 1; /* use of a SUM statement causes automatic retain */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Nov 2020 05:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Surrogate-Key-and-SCD-type-2-in-SAS-Studio-by-code/m-p/698076#M213451</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-11T05:53:16Z</dc:date>
    </item>
  </channel>
</rss>

