<?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: Adding a new column to confirm the date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878432#M38991</link>
    <description>&lt;P&gt;Apologies for that.&lt;/P&gt;
&lt;P&gt;Data Confirm_DOB; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Date_of_birth $;&lt;BR /&gt;datalines ; &lt;BR /&gt;11902164 100079300 899 12DEC63&lt;BR /&gt;4642984 100167774 891V 02JAN64&lt;BR /&gt;4642984 100167915 899 02JAN64&lt;BR /&gt;13622248 10086855 398M 10OCT69&lt;BR /&gt;19939961 101134922 2H12 14DEC70&lt;BR /&gt;9400191 105616411 503 28MAR84&lt;BR /&gt;9400191 105616429 503 28MAR84&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 14:08:56 GMT</pubDate>
    <dc:creator>Sandeep77</dc:creator>
    <dc:date>2023-05-31T14:08:56Z</dc:date>
    <item>
      <title>Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878409#M38984</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I have a dataset which has few common icustomerid. I want to find how many of the common icustomerid have same date of birth and how many common icustomerid have different date of birth. Can you please suggest? For e.g. output data shows me that common icustomerid have the same date_of_birth then 1.&lt;/P&gt;
&lt;P&gt;Here is the sample dateset&lt;/P&gt;
&lt;P&gt;Data Confirm_DOB; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Date_of_birth $;&lt;BR /&gt;datalines ; &lt;BR /&gt;11902164 100079300 899 12DEC1963:00:00:00.000&lt;BR /&gt;4642984 100167774 891V 02JAN1964:00:00:00.000&lt;BR /&gt;4642984 100167915 899 02JAN1964:00:00:00.000&lt;BR /&gt;13622248 10086855 398M 10OCT1969:00:00:00.000&lt;BR /&gt;19939961 101134922 2H12 14DEC1970:00:00:00.000&lt;BR /&gt;9400191 105616411 503 28MAR1984:00:00:00.000&lt;BR /&gt;9400191 105616429 503 28MAR1984:00:00:00.000&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878409#M38984</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-31T13:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878412#M38985</link>
      <description>&lt;P&gt;Your code doesn't work properly, the dates seem to have a character missing. Could you please fix it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1685539578882.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84522i1335058A5D6E2E79/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1685539578882.png" alt="PaigeMiller_0-1685539578882.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, what is the desired output of this analysis? What does it mean "&lt;SPAN&gt;how many common icustomerid have different date of birth" — different than what?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878412#M38985</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-31T13:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878416#M38986</link>
      <description>&lt;P&gt;I am looking to find that all the common icustomerid have same date of birth. We can see in the sample data that icustomerid 4642984 and 9400191 have multiple records. I want to check if those multiple records have same date of birth. E.g. icustomerid 4642984 have two debt_code and they have same date of birth then flag it as 1 and if any other icustomer have two debt_code and they have different date of birth then flag it as 0. Hope that makes sense.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878416#M38986</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-31T13:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878418#M38987</link>
      <description>&lt;P&gt;What if there are three records for icustomerid, two have the same date of birth and one has a different date of birth?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please fix your code?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878418#M38987</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-31T13:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878421#M38988</link>
      <description>&lt;P&gt;If there are three records then two with same date to be marked as 1 and the other odd date of birth to be 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Confirm_DOB; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Date_of_birth $;&lt;BR /&gt;datalines ; &lt;BR /&gt;11902164 100079300 899 12DEC63&lt;BR /&gt;4642984 100167774 891V 02JAN64&lt;BR /&gt;4642984 100167915 899 02JAN1964&lt;BR /&gt;13622248 10086855 398M 10OCT69&lt;BR /&gt;19939961 101134922 2H12 14DEC70&lt;BR /&gt;9400191 105616411 503 28MAR84&lt;BR /&gt;9400191 105616429 503 28MAR84&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878421#M38988</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-31T13:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878425#M38989</link>
      <description>&lt;P&gt;Still not correct&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1685541289563.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84525i3A684555D053FC5B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1685541289563.png" alt="PaigeMiller_0-1685541289563.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878425#M38989</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-31T13:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878432#M38991</link>
      <description>&lt;P&gt;Apologies for that.&lt;/P&gt;
&lt;P&gt;Data Confirm_DOB; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Date_of_birth $;&lt;BR /&gt;datalines ; &lt;BR /&gt;11902164 100079300 899 12DEC63&lt;BR /&gt;4642984 100167774 891V 02JAN64&lt;BR /&gt;4642984 100167915 899 02JAN64&lt;BR /&gt;13622248 10086855 398M 10OCT69&lt;BR /&gt;19939961 101134922 2H12 14DEC70&lt;BR /&gt;9400191 105616411 503 28MAR84&lt;BR /&gt;9400191 105616429 503 28MAR84&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 14:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878432#M38991</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-31T14:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878461#M38996</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=confirm_dob;
    by icustomerid date_of_birth;
run;

proc freq data=confirm_dob;
    tables icustomerid*date_of_birth/noprint out=_counts_;
run;

data want;
    merge confirm_dob _counts_(keep=icustomerID date_of_birth count);
    by icustomerid date_of_birth;
    if count&amp;gt;=2 then new_variable=1;
    else new_variable=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should work. You should not be treating dates as character strings, they should be numeric as a general rule, and making dates numeric is simply a good practice and a good habit to get into. In this case, I have left them as character because it doesn't matter in this problem; in most problems it will matter.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 15:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878461#M38996</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-31T15:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a new column to confirm the date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878462#M38997</link>
      <description>&lt;P&gt;Why do you treat dates, or datetime values as character?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you provide a data step to read character data and expect to get longer than the default 8 characters either provide a LENGTH statement to set the expected length or use an informat long enough to read the expected results such as:&lt;/P&gt;
&lt;PRE&gt;Data Confirm_DOB;
infile cards expandtabs;
input icustomerid debt_code rep_code $ Date_of_birth :$22.;
datalines ;
11902164 100079300 899 12DEC1963:00:00:00.000
4642984 100167774 891V 02JAN1964:00:00:00.000
4642984 100167915 899 02JAN1964:00:00:00.000
13622248 10086855 398M 10OCT1969:00:00:00.000
19939961 101134922 2H12 14DEC1970:00:00:00.000
9400191 105616411 503 28MAR1984:00:00:00.000
9400191 105616429 503 28MAR1984:00:00:00.000
; &lt;/PRE&gt;
&lt;P&gt;IMHO anyone that provides dates with :00:00:00.000 is just wasting electrons and storage bytes somewhere. Lazy programmer no cookie.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One reason not to use character dates is that you don't have a clue when the value is not actually a valid date. Consider this minor modification has no concern about the 42d day of December.&lt;/P&gt;
&lt;PRE&gt;Data Confirm_DOB;
infile cards expandtabs;
input icustomerid debt_code rep_code $ Date_of_birth :$22.;
datalines ;
11902164 100079300 899 42DEC1963:00:00:00.000
4642984 100167774 891V 02JAN1964:00:00:00.000
4642984 100167915 899 02JAN1964:00:00:00.000
13622248 10086855 398M 10OCT1969:00:00:00.000
19939961 101134922 2H12 14DEC1970:00:00:00.000
9400191 105616411 503 28MAR1984:00:00:00.000
9400191 105616429 503 28MAR1984:00:00:00.000
; &lt;/PRE&gt;
&lt;P&gt;If you use an actual date informat SAS will tell you that you invalid data:&lt;/P&gt;
&lt;PRE&gt;210  Data Confirm_DOB;
211  infile cards expandtabs;
212  input icustomerid debt_code rep_code $ Date_of_birth :date9.;
213  format date_of_birth date9.;
214  datalines ;

NOTE: Invalid data for Date_of_birth in line 215 24-45.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
215        11902164 100079300 899 42DEC1963:00:00:00.000
icustomerid=11902164 debt_code=100079300 rep_code=899 Date_of_birth=. _ERROR_=1 _N_=1
NOTE: The data set WORK.CONFIRM_DOB has 7 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


&lt;/PRE&gt;
&lt;P&gt;So you can fix, maybe, the values before proceeding to something that actually attempts to use those dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 15:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-a-new-column-to-confirm-the-date/m-p/878462#M38997</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-31T15:10:27Z</dc:date>
    </item>
  </channel>
</rss>

