<?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: formatting dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328161#M73256</link>
    <description>&lt;P&gt;You say the original variable is numeric, what format is attached to the date variable? If you say not working, please post the exact code you used and the log. &amp;nbsp;Ideally, data so we can replicate your question.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Jan 2017 22:22:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-01-27T22:22:10Z</dc:date>
    <item>
      <title>formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328145#M73247</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I posted this question before but this time I'm getting a different solution when I tried to convert date to mmddyy10. format.&lt;/P&gt;&lt;P&gt;The dataset has a varaible "createddate" as 20150211 and I'm trying to change it to 02/11/2015 format. Createddate is a numeric var. I tried to convert it to char first and then format to mmddyy10. But it is not working moreover it's giving missing values and the dates are going back to 2002 rather than 2015.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; raw;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;createdon=put(createdon,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;z8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;created=input(createdon,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;yymmdd8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; createdon &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;mmddyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; createdon1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I also tried nesting the input and put function as I did from the previous post. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;created0n=input(put(createdon, z8.),?? yymmdd8.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;but both ways it is generating missing values and is going back to 2002 date which is not in the dataset. The dataset has only 2015 dates.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;One of the error message is:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NOTE: Invalid numeric data, '03/09/2015' , at line 3153 column 11.&lt;/P&gt;&lt;P&gt;WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.&lt;/P&gt;&lt;P&gt;createdon=. filecreatedate=20150316 soldto_customernumber=10045343 shipto_customernumber=.&lt;/P&gt;&lt;P&gt;salesdocnumber=108473239 salesitem=50 dtcnumber=10045343 ordermethod=ZPHO createdby=ET26EO4&lt;/P&gt;&lt;P&gt;pono=ATTN STACEY PREPARE TONER orderreason= reason_rejected=&lt;/P&gt;&lt;P&gt;itemdescription=Obagi Tretinoin 0.05% Cream 20G 1/ea qty_ordered=12.000 uom=EA freegoods=N&lt;/P&gt;&lt;P&gt;del_block= shipto_address1=5005 ROCKSIDE RD #1225 shipto_address2= shipto_city=INDEPENDENCE&lt;/P&gt;&lt;P&gt;shipto_state=OH shipto_postalcode=44131 soldto_customername=NICHOLAS HUSNI MD INC&lt;/P&gt;&lt;P&gt;referencedocnumber=. referenceitemnumber=0 doctype=ZDOR itemcategory=ZDTN extendedprice=498&lt;/P&gt;&lt;P&gt;net_sell_price=473.16 discountamt=24.84 discountpct=4.99 unitprice=41.5 shipto_customername=&lt;/P&gt;&lt;P&gt;item_no=5005005 prod_lin=TRETINOIN prod_fam=TRETINOIN prod_cat=RX prod_grp=TRET createdon1=.&lt;/P&gt;&lt;P&gt;_ERROR_=1 _N_=20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;And the other is&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 3136 column 9.&lt;/P&gt;&lt;P&gt;WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.&lt;/P&gt;&lt;P&gt;createdon=20150309 filecreatedate=20150316 soldto_customernumber=10045343&lt;/P&gt;&lt;P&gt;shipto_customernumber=. salesdocnumber=108473239 salesitem=50 dtcnumber=10045343&lt;/P&gt;&lt;P&gt;ordermethod=ZPHO createdby=ET26EO4 pono=ATTN STACEY PREPARE TONER orderreason=&lt;/P&gt;&lt;P&gt;reason_rejected= itemdescription=Obagi Tretinoin 0.05% Cream 20G 1/ea qty_ordered=12.000&lt;/P&gt;&lt;P&gt;uom=EA freegoods=N del_block= shipto_address1=5005 ROCKSIDE RD #1225 shipto_address2=&lt;/P&gt;&lt;P&gt;shipto_city=INDEPENDENCE shipto_state=OH shipto_postalcode=44131&lt;/P&gt;&lt;P&gt;soldto_customername=NICHOLAS HUSNI MD INC referencedocnumber=. referenceitemnumber=0&lt;/P&gt;&lt;P&gt;doctype=ZDOR itemcategory=ZDTN extendedprice=498 net_sell_price=473.16 discountamt=24.84&lt;/P&gt;&lt;P&gt;discountpct=4.99 unitprice=41.5 shipto_customername= item_no=5005005 prod_lin=TRETINOIN&lt;/P&gt;&lt;P&gt;prod_fam=TRETINOIN prod_cat=RX prod_grp=TRET createdon1=. created=. _ERROR_=1 _N_=20&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed at the following places. The results of&lt;/P&gt;&lt;P&gt;the operations have been set to missing values.&lt;/P&gt;&lt;P&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;/P&gt;&lt;P&gt;764004 at 3136:9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thank you&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Malathi&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 21:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328145#M73247</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2017-01-27T21:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328150#M73250</link>
      <description>&lt;P&gt;createdon is the result of a put function and therefore of type character; you can`t assign a date format (which is numeric) to it.&lt;/P&gt;
&lt;P&gt;Your codepiece should probably look like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;createdon1=put(createdon,z8.);
createdon=input(createdon1,yymmdd8.);
format createdon mmddyy10.;
drop createdon1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Jan 2017 21:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328150#M73250</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-27T21:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328157#M73252</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;I tried that code but still it is giving me missing values and the value of the date is 2002. I don't understand when the dataset has only 2015 data why it is showing me 2002? That's so weird date I'm getting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Malathi&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 21:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328157#M73252</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2017-01-27T21:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328161#M73256</link>
      <description>&lt;P&gt;You say the original variable is numeric, what format is attached to the date variable? If you say not working, please post the exact code you used and the log. &amp;nbsp;Ideally, data so we can replicate your question.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 22:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328161#M73256</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-27T22:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328162#M73257</link>
      <description>Use date9. instead of z8.&lt;BR /&gt;&lt;BR /&gt;createdon1=put(createdon,date9.);</description>
      <pubDate>Fri, 27 Jan 2017 22:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328162#M73257</guid>
      <dc:creator>anoopmohandas7</dc:creator>
      <dc:date>2017-01-27T22:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328164#M73259</link>
      <description>&lt;P&gt;A sample code in case u want to test.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input createdon yymmdd8. ;
datalines ;
20150211
run ;

data new ;
set have ;
createdon1=put(createdon,date8.);
createdon=input(createdon1,anydtdte15.);
format createdon mmddyy10. ;
drop createdon1;
run;

proc print data=new;run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Jan 2017 22:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328164#M73259</guid>
      <dc:creator>anoopmohandas7</dc:creator>
      <dc:date>2017-01-27T22:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328167#M73261</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91804"&gt;@Malathi13&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Kurt,&lt;/P&gt;
&lt;P&gt;I tried that code but still it is giving me missing values and the value of the date is 2002. I don't understand when the dataset has only 2015 data why it is showing me 2002? That's so weird date I'm getting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Malathi&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show the code and the log. And at least one orginal value that results in 2002 from 2015.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 22:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328167#M73261</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-27T22:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328178#M73262</link>
      <description>&lt;P&gt;It's a little bit of a mismatch. &amp;nbsp;You have a numeric variable createddate, but your code doesn't refer to that in any way. &amp;nbsp;Using that name, and assuming it is a numeric variable that needs to be converted to a date, these statements would do the trick:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;createddate&amp;nbsp;= input( put(createddate,z8.), yymmdd8.);&lt;/P&gt;
&lt;P&gt;format createddate&amp;nbsp;mmddyys10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2017 00:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328178#M73262</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-28T00:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328189#M73263</link>
      <description>&lt;P&gt;in the case of missing values please have a look into, the place from which the column is getting imported from and applay the format at that level for avoiding any confusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SO at that level itself add:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;input ( put (DateCol, Z8.) , yymmdd8.);&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2017 03:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328189#M73263</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-28T03:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: formatting dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328426#M73330</link>
      <description>&lt;P&gt;Thank you so so much Anoopmohandas7. It worked perfectly without creating a new varaible and with no missing values. Also the date is in 2015 not 2002.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt;Malathi&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 14:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-dates/m-p/328426#M73330</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2017-01-30T14:19:52Z</dc:date>
    </item>
  </channel>
</rss>

