<?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 Formatting date to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368014#M87690</link>
    <description>&lt;P&gt;I wasn't able to find a way&amp;nbsp;on how to convert the following date format to numeric:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;27Oct2003&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;20031027&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions will be appreciated.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Jun 2017 04:16:31 GMT</pubDate>
    <dc:creator>Yegen</dc:creator>
    <dc:date>2017-06-18T04:16:31Z</dc:date>
    <item>
      <title>Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368014#M87690</link>
      <description>&lt;P&gt;I wasn't able to find a way&amp;nbsp;on how to convert the following date format to numeric:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;27Oct2003&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;20031027&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions will be appreciated.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368014#M87690</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368015#M87691</link>
      <description>&lt;P&gt;What's your variable type/format from proc contents?&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 01:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368015#M87691</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-18T01:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368017#M87693</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;input date date9. ;&lt;BR /&gt;cards;&lt;BR /&gt;21oct2010&lt;BR /&gt;30sep2011&lt;BR /&gt;07jan2012&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data want; set have;&lt;BR /&gt;new_date=compress(day(date)||month(date)||year(date));&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 01:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368017#M87693</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2017-06-18T01:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368018#M87694</link>
      <description>&lt;P&gt;The trick is to set the format of the date in the original database (date9.)&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 01:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368018#M87694</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2017-06-18T01:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368019#M87695</link>
      <description>&lt;P&gt;Your date is numeric to start with. Just apply the format you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt;input date date9. ;&lt;BR /&gt;format date yymmddn8.;&lt;BR /&gt;cards;&lt;BR /&gt;21oct2010&lt;BR /&gt;30sep2011&lt;BR /&gt;07jan2012&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print data = have;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 01:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368019#M87695</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-06-18T01:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368032#M87705</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&amp;nbsp;the type is Char and the&amp;nbsp;format (and informat) is $10.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368032#M87705</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368033#M87706</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;when I took your&amp;nbsp;code to the actual data, I am getting the below&amp;nbsp;error.&lt;BR /&gt;&lt;BR /&gt;The code I have used:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*This is what I have tried;
data IMPORT1;
	set IMPORT1;
	newdate = input(put(ex_post_date,DATE9.),yymmddn8.);
run;

*But I have also tried;
data IMPORT1;
  set IMPORT1;
  format ex_post_date date9.;
  newdate1=datepart(ex_post_date);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;This is the error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         data IMPORT1;
 63           set IMPORT1;
 64           format ex_post_date date9.;
                                  ______
                                  484
 NOTE 484-185: Format $DATE was not found or could not be loaded.
 
 65           newdate1=datepart(ex_post_date);
 66         run;
 
 NOTE: Character values have been converted to numeric 
       values at the places given by: (Line):(Column).
       65:21   
 NOTE: Invalid numeric data, Ex_post_date='30SEP1984' , at line 65 column 21.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368033#M87706</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368034#M87707</link>
      <description>&lt;P&gt;Thank&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87866"&gt;@soumri&lt;/a&gt;, but I am getting the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Invalid numeric data, Ex_post_date='31MAR1996' , at line 64 column 25.
NOTE: Invalid numeric data, Ex_post_date='31MAR1996' , at line 64 column 46.
NOTE: Invalid numeric data, Ex_post_date='31MAR1996' , at line 64 column 65.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will
not be printed.
Acquiror_name=APP Acquiror_mgrno1=9999 Target_name=SBZ
Target_mgrno1=8888 Announcement_date=19941128 Effective_date=19970412
Announcement=28Nov1994 Effective=12Apr1997 Ex_post_date=31MAR1999 Merger_ID=AS
Who continues?=Acquiror Mgrno=49240 Target ends in=30SEP1996 Note Ex Post=
Note 1= Note 2= Note 3= Note 4 Target:= new_date=... _ERROR_=1 _N_=20
NOTE: Missing values were generated as a result of performing an operation on
missing values.
Each place is given by: (Number of times) at (Line):(Column).
60 at 64:20 60 at 64:40 60 at 64:61
NOTE: There were 60 observations read from the data set WORK.IMPORT1.
NOTE: The data set WORK.IMPORT1 has 60 observations and 19 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368034#M87707</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368036#M87708</link>
      <description>&lt;P&gt;is your date is currently numeric or in character&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368036#M87708</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-18T04:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368038#M87709</link>
      <description>&lt;P&gt;Here is the information&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9463iBCF06C8E9E2C44C1/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Format" title="Format" /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368038#M87709</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368039#M87710</link>
      <description>&lt;P&gt;To read a character string into a numeric date value use the INPUT function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = input(char_date,date9.);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then attach a format to it to have it appear in the format you specified.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format date yymmddn8.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If instead you wanted to convert it to a number 19,840,930 that would look like a date in YYYYMMDD if printed without thousands seperators then you could use code like.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_like_number = input(put(input(char_date,date9.),yymmddn8.),8.);
format date_like_number 8.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368039#M87710</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-18T04:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368040#M87711</link>
      <description>&lt;DIV class="proc_title_group"&gt;&lt;P class="c proctitle"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="c proctitle"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The CONTENTS Procedure:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp; Alphabetic List of Variables and Attributes # Variable Type Len Format Informat Label&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Acquiror_mgrno1&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;BEST.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Acquiror_mgrno1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Acquiror_name&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;$27.&lt;/TD&gt;&lt;TD&gt;$27.&lt;/TD&gt;&lt;TD&gt;Acquiror_name&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Announcement&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;$9.&lt;/TD&gt;&lt;TD&gt;$9.&lt;/TD&gt;&lt;TD&gt;Announcement&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Announ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TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;BEST.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Target_mgrno1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Target_name&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;29&lt;/TD&gt;&lt;TD&gt;$29.&lt;/TD&gt;&lt;TD&gt;$29.&lt;/TD&gt;&lt;TD&gt;Target_name&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Who continues?&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;$28.&lt;/TD&gt;&lt;TD&gt;$28.&lt;/TD&gt;&lt;TD&gt;Who continues?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368040#M87711</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368041#M87712</link>
      <description>&lt;P&gt;I have used the format given by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;and used for char variable you have and it worked fine for me&lt;/P&gt;
&lt;PRE&gt;data have;
informat ex_post_date $9.;
input ex_post_date $;
cards;
21oct2010
30sep2011
07jan2012
;
run;

data want(rename= (ex_post_date1= ex_post_date));
set have;
ex_post_date1 = input(ex_post_date,date9.);
drop ex_post_date;
format ex_post_date1 yymmddn8.;
 run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368041#M87712</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-18T04:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368043#M87714</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;, your code worked very well. However, since&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s reply was first and his worked as well, I accepted his answer.&amp;nbsp;Thank&amp;nbsp;you very&amp;nbsp;to you both for your helpful answers.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 04:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368043#M87714</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T04:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368054#M87722</link>
      <description>&lt;P&gt;Hi again, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&amp;nbsp;I have just tried to use the new variable in an artimethic computation even though I have change the Char format to a Numeric format, but it did not work. Even if I change it to Best format, it still doesn't work. The reason why I have tried to change it again to Best is that there was another variables that is in the Best format and the computation worked well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have(rename= (ex_post_date1= ex_post_date));
	set have;
	ex_post_original=ex_post_date;
	ex_post_date1 = input(ex_post_date,date9.);
	drop ex_post_date;
	format ex_post_date1 yymmddn8.;
run;

data have;
	set have;
	numeric=put(ex_post_date1,best8.);
	format ex_post_date1 best8.;
run;


*Here is the math computation;
data want;
	set have;
	year=int(ex_post_date/10000);
	month=int(ex_post_date/100)-year*100;
	day=ex_post_date-year*10000-month*100;
	NEED_num=mdy(month,day,year);
	format NEED_num mmddyy10.;
	drop year month day;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 06:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368054#M87722</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T06:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368058#M87726</link>
      <description>&lt;P&gt;the way date is stored in SAS as that it starts from 1/1/1960. So it is not fitting in your calculation. So when you are calculating with date it does not work. below thing may work&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;BR /&gt; data want;&lt;BR /&gt; set want;&lt;BR /&gt; numeric=put(ex_post_date,best8.);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; data wantfinal;&lt;BR /&gt; set want;&lt;BR /&gt; year=year(numeric);&lt;BR /&gt; month=month(numeric);&lt;BR /&gt; day=day(numeric);&lt;BR /&gt; NEED_num=mdy(month,day,year);&lt;BR /&gt; format NEED_num mmddyy10.;&lt;BR /&gt; drop year month day;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 06:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368058#M87726</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-18T06:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368060#M87727</link>
      <description>&lt;P&gt;Please review how SAS stores date variables. It counts it as the number of days. So that num_needed is actually what you got from the INPUT() from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;s answer. If you want day/month/year, use those respective functions on the date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please run the following and then look at the proc contents of the data set, types/formats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data sample;
D1 = '01Jan2009';* -&amp;gt; character;

D2 = input(D1, DATE9.); *SAS date;
D3 = D2; *SAS date, formatted;

Format D3 ddmmyy10.;

M = month(d2);
D = day(d2);
Y = year(d2);

Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Jun 2017 06:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368060#M87727</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-18T06:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368065#M87731</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, thanks for this helpful suggestion. The code works very well. You are right in regards to being careful how SAS stores date variables. I will look into it now.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 07:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368065#M87731</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T07:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368066#M87732</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;, thanks for your reply. The&amp;nbsp;code didn't work, unfortunately, work. However,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s suggestion works well.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks to you both again.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 07:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368066#M87732</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2017-06-18T07:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368082#M87738</link>
      <description>&lt;P&gt;You are still not getting the difference between a character variable and a numeric variable and the meaning of a format. &amp;nbsp;The format is just instructions on how to display value. &amp;nbsp;The PUT() function will always return character strings. Then INPUT() function can return either numeric or character values based on the type of INFORMAT used as the second argument. &amp;nbsp;There is a BEST format that will try to fit a number into the width specified. THere is isn't really a BEST informat, but if you use it then SAS will silently convert to using the normal numeric informat which handles and values that the BEST format would write.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's rewrite your posted code using variable names that will help understand what they contain.&lt;/P&gt;
&lt;P&gt;So let's start with a character variable that has strings that look like dates in DATE9 format. &amp;nbsp;We can use the INPUT() function to convert that to a date. &amp;nbsp;We can make copies of it into other variables so we can apply different formats to them to see how they print. &amp;nbsp;We could use an INPUT(PUT()) sandwich to convert the date to a number with the days in the ones and tens places. &amp;nbsp;We can use the MONTH(),DAY() and YEAR() functions to convert a date value into its parts. Or we could use arthimetic to convert a number that is in the format YY,YYM,MDD into the year, month and day values. &amp;nbsp;We can use the MDY() function to generate a date value from month day and year values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input char_date $9.;
cards;
01JAN1960
14JUN2017
;

data want ;
  set have (keep=char_date);
  date1 = input(char_date,date9.);
  date2 = date1;
  date_unformatted=date1;
  format date1 date9. date2 yymmddn8.;
  number = input(put(date1,yymmddn8.),8.);
  year1=year(date1);
  month1=month(date1);
  day1=day(date1);
  year2=int(number/10000);
  month2=int(mod(number,10000)/100);
  day2=mod(number,100);
  new_date=mdy(month1,day1,year1);
  format char_date $quote. ;
  format date1 date9. date2 yymmddn8. new_date mmddyy10.;
  format number date_unformatted comma10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I purposely using the $QUOTE and COMMA formats so that when you print the values you can tell which variables are character and non-date numbers.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9466iCA5A76EC73FD4240/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 12:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-date-to-numeric/m-p/368082#M87738</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-18T12:20:54Z</dc:date>
    </item>
  </channel>
</rss>

