<?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: Two different date formats in on variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619223#M181752</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Satish,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried to run the code as you have suggested but I think I want to do it differently. My Date of Birth variable has values like '201702' and some values are missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And Attendance_date has two different formats like; 201903 and 20150623.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have read the two fields as character $8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do following;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Derive the age of participants from Dob and attendance_date. Please suggest the best possible way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please provide explicit examples of your input and the desired actual date you want them treated as.&lt;/P&gt;
&lt;P&gt;And do you want Age in years as commonly done or year and fractional part or some other unit?&lt;/P&gt;
&lt;P&gt;The first step is going to settle on a base rule for the incomplete dates. So specify if that 201903 is supposed to be the first day of March in 2019, another day in March in 2019, or something else. Note that 6 character dates can have lots of interpretations and you need to explicitly tell us what you want to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example: 010203 could be 02JAN2003 , 03Feb2001, 01Feb2003&amp;nbsp; or the years might be 1903, 1901 or 1903. Any 2 digit year is hightly suspect in my book.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jan 2020 16:47:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-01-22T16:47:00Z</dc:date>
    <item>
      <title>Two different date formats in on variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619094#M181700</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date variable with two different date formats; like 201703 and 20170319.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I re-code to generate a single format please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ta&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 10:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619094#M181700</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2020-01-22T10:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Two different date formats in on variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619097#M181702</link>
      <description>Where the data is stored, is it in a SAS dataset or any other format e.g. Excel, CSV.&lt;BR /&gt;If it is in SAS Dataset, Is the variable a Character or a Numeric Data Variable?</description>
      <pubDate>Wed, 22 Jan 2020 10:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619097#M181702</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-01-22T10:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Two different date formats in on variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619098#M181703</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is stored in a CSV&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 10:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619098#M181703</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2020-01-22T10:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Two different date formats in on variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619103#M181707</link>
      <description>&lt;P&gt;I would suggest to use a data step to read the CSV file.&lt;BR /&gt;1. Then read the particular variable as a character.&lt;BR /&gt;2. add some default date when the date field is absent.&lt;BR /&gt;3. Convert the char date to number date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example code snippet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input f_date:$8.;

if length(f_date)&amp;lt;8 then t_date=cats(f_date,'01'); /*01 is some random number*/
else t_date=f_date;

a_date=input(t_date,yymmdd8.);

cards;
201703
20170319
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2020 10:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619103#M181707</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-01-22T10:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Two different date formats in on variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619196#M181742</link>
      <description>&lt;P&gt;Hi Satish,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to run the code as you have suggested but I think I want to do it differently. My Date of Birth variable has values like '201702' and some values are missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And Attendance_date has two different formats like; 201903 and 20150623.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have read the two fields as character $8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do following;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Derive the age of participants from Dob and attendance_date. Please suggest the best possible way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 15:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619196#M181742</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2020-01-22T15:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Two different date formats in on variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619223#M181752</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Satish,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried to run the code as you have suggested but I think I want to do it differently. My Date of Birth variable has values like '201702' and some values are missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And Attendance_date has two different formats like; 201903 and 20150623.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have read the two fields as character $8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do following;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Derive the age of participants from Dob and attendance_date. Please suggest the best possible way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please provide explicit examples of your input and the desired actual date you want them treated as.&lt;/P&gt;
&lt;P&gt;And do you want Age in years as commonly done or year and fractional part or some other unit?&lt;/P&gt;
&lt;P&gt;The first step is going to settle on a base rule for the incomplete dates. So specify if that 201903 is supposed to be the first day of March in 2019, another day in March in 2019, or something else. Note that 6 character dates can have lots of interpretations and you need to explicitly tell us what you want to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example: 010203 could be 02JAN2003 , 03Feb2001, 01Feb2003&amp;nbsp; or the years might be 1903, 1901 or 1903. Any 2 digit year is hightly suspect in my book.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 16:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-different-date-formats-in-on-variable/m-p/619223#M181752</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-22T16:47:00Z</dc:date>
    </item>
  </channel>
</rss>

