<?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: Create macro for to cross check the uniqueness of employee id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173650#M33337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks cynthia .&lt;/P&gt;&lt;P&gt;Its a interview question asked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Aug 2014 18:05:35 GMT</pubDate>
    <dc:creator>venkatnaveen</dc:creator>
    <dc:date>2014-08-24T18:05:35Z</dc:date>
    <item>
      <title>Create macro for to cross check the uniqueness of employee id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173648#M33335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="EN-IN"&gt;There is a list of employee ID and every month a &lt;SPAN class="orh2e03k0r" id="orh2e03k0r_6" style="font-weight: bold;"&gt;new employee&lt;/SPAN&gt; is added. Write a Macro program to &lt;SPAN class="orh2e03k0r" id="orh2e03k0r_5" style="font-weight: bold;"&gt;cross check&lt;/SPAN&gt; the uniqueness of the employee ID. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 17:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173648#M33335</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2014-08-24T17:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro for to cross check the uniqueness of employee id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173649#M33336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; You do not need a macro program to do this. Simply create a temporary file for the new month and then use PROC FREQ with nlevels. Any EmpID with nlevel=2 is a duplicate. Or use PROC SORT with the DUPOUT option. Or define an index for Employee ID in the main/master file to have the UNIQUE property and you will not be able to add duplicate employee IDs to the master file. This sounds like a homework problem. What code have you tried? Even if you do ultimately want a macro program, you have to start with a working SAS program before you "macro-ize" it. So, show your work. What does the input data look like for the "master" file? What does the data look like for the monthly add? What is the working program to add the new observation(s) to the master file?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 18:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173649#M33336</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2014-08-24T18:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro for to cross check the uniqueness of employee id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173650#M33337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks cynthia .&lt;/P&gt;&lt;P&gt;Its a interview question asked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 18:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173650#M33337</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2014-08-24T18:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro for to cross check the uniqueness of employee id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173651#M33338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a general rule a macro is only useful if it is to be repeated multiple times in your SAS jobs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore it might be a good idea to have general "check for duplicates" macro that could be applied to any dataset with a key variable and not just employee ID. Here is an example and this is one way of answering your interviewer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 9pt; background: white; font-family: Consolas;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; Find_Dups ( dataset = &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&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; ,byvar&amp;nbsp;&amp;nbsp; =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&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; ,dupvar&amp;nbsp; = &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&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; );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 9pt;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; &amp;amp;dupvar = &lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 9pt;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; dupvar = &amp;amp;byvar; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;proc sort data = &amp;amp;dataset &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out = sorted&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp; by &amp;amp;byvar;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;data dups;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp; set sorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; by &amp;amp;byvar;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp; if not (&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: teal; font-size: 9pt;"&gt;first.&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;amp;dupvar and &lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: teal; font-size: 9pt;"&gt;last.&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;amp;dupvar);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 9pt; background: white; font-family: Consolas;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt; Find_Dups;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;%Find_Dups( dataset = MyData&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,byvar = EmployeeID);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 20:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173651#M33338</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2014-08-24T20:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro for to cross check the uniqueness of employee id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173652#M33339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a ton.&lt;/P&gt;&lt;P&gt;Good explanation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 07:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-for-to-cross-check-the-uniqueness-of-employee-id/m-p/173652#M33339</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2014-08-25T07:56:36Z</dc:date>
    </item>
  </channel>
</rss>

