<?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: Covert date from character or numeric before append in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648986#M194510</link>
    <description>&lt;P&gt;If I understand correctly you have dates represented in different variable types and need to be manipulated to a standard format into one dataset. See if this SQL solution works for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql ;
   create table want as
      select a.id
           , input(put(a.date,z8.),mmddyy8.) as date format = mmddyy10. 
        from a
      outer union corr
      select b.id
           , input(b.date,mmddyy10.) as date format = mmddyy10.
        from b
   ;
quit ;
&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 May 2020 19:15:35 GMT</pubDate>
    <dc:creator>biopharma</dc:creator>
    <dc:date>2020-05-19T19:15:35Z</dc:date>
    <item>
      <title>Covert date from character or numeric before append</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648948#M194499</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to create an append dataset with the date variable in mmddyy10 from the source datasets. For example, one of the source dataset (a) has date variable in numeric (9012010 means Sep. 01 2020) and the other source dataset (b) has the date in character. Thank you so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input id $ date;&lt;BR /&gt;datalines;&lt;BR /&gt;1 9012010&lt;BR /&gt;1 10022010&lt;BR /&gt;2 9032010&lt;BR /&gt;2 10092010&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data b;&lt;BR /&gt;input id $ date $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 04/15/2017&lt;BR /&gt;1 11/09/2016&lt;BR /&gt;2 11/10/2016&lt;BR /&gt;2 02/01/2017&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 18:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648948#M194499</guid>
      <dc:creator>CHL0320</dc:creator>
      <dc:date>2020-05-19T18:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Covert date from character or numeric before append</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648950#M194500</link>
      <description>9012010 means Sep. 01 2010</description>
      <pubDate>Tue, 19 May 2020 18:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648950#M194500</guid>
      <dc:creator>CHL0320</dc:creator>
      <dc:date>2020-05-19T18:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Covert date from character or numeric before append</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648953#M194503</link>
      <description>&lt;P&gt;It is not clear what your expected output is, but let's just show you how to convert both of those to actual date values.&lt;/P&gt;
&lt;P&gt;First let's fix the code for B so that it reads the whole date string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b;
input id $ date :$10.;
datalines;
1 04/15/2017
1 11/09/2016
2 11/10/2016
2 02/01/2017
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now here is how you could convert those two datasets to have a numeric variable named DATE that actual has a DATE value in it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fix_a;
  set a;
  want=input(put(date,z8.),mmddyy8.);
  format want yymmdd10.;
  rename date=date_numeric want=date;
run;
data fix_b;
  set b;
  want=input(date,mmddyy10.);
  format want yymmdd10.;
  rename date=date_string want=date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can put them together if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data both;
  set fix_a fix_b;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;               date_                     date_
Obs    id     numeric          date      string

 1     1      9012010    2010-09-01
 2     1     10022010    2010-10-02
 3     2      9032010    2010-09-03
 4     2     10092010    2010-10-09
 5     1            .    2017-04-15    04/15/2017
 6     1            .    2016-11-09    11/09/2016
 7     2            .    2016-11-10    11/10/2016
 8     2            .    2017-02-01    02/01/2017&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 18:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648953#M194503</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-19T18:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Covert date from character or numeric before append</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648986#M194510</link>
      <description>&lt;P&gt;If I understand correctly you have dates represented in different variable types and need to be manipulated to a standard format into one dataset. See if this SQL solution works for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql ;
   create table want as
      select a.id
           , input(put(a.date,z8.),mmddyy8.) as date format = mmddyy10. 
        from a
      outer union corr
      select b.id
           , input(b.date,mmddyy10.) as date format = mmddyy10.
        from b
   ;
quit ;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 May 2020 19:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/648986#M194510</guid>
      <dc:creator>biopharma</dc:creator>
      <dc:date>2020-05-19T19:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Covert date from character or numeric before append</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/649012#M194517</link>
      <description>&lt;P&gt;Read the data properky, so you have SAS dates in the first place.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id $ temp;
date = input(put(temp,8.),mmddyy8.);
format date yymmddd10.;
drop temp;
datalines;
1 9012010
1 10022010
2 9032010
2 10092010
;

data b;
input id $ date mmddyy10.;
format date yymmddd10.;
datalines;
1 04/15/2017
1 11/09/2016
2 11/10/2016
2 02/01/2017&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 May 2020 20:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/649012#M194517</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-19T20:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Covert date from character or numeric before append</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/649014#M194519</link>
      <description>Note you could read both sets of records using the same input statement.&lt;BR /&gt;  input id $ date :mmddyy. ;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 May 2020 20:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Covert-date-from-character-or-numeric-before-append/m-p/649014#M194519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-19T20:28:26Z</dc:date>
    </item>
  </channel>
</rss>

