<?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: How to change the number to date? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174413#M264561</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems like a rather roundabout way to define a date, why not just write&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test4;&lt;/P&gt;&lt;P&gt;set test3;&lt;/P&gt;&lt;P&gt;if T2DM=0 then Diag_day='01JAN1998'd;&lt;/P&gt;&lt;P&gt;format Diag_day mmddyy10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially if T2DM is equal to 0 then diag_day is converted to the SAS date for 01/01/1998&lt;/P&gt;&lt;P&gt;Also this way you don't have to create an extra variable in Diag_day_Q which you likely will have to delete in the future, or have to make sure that your substr commands are all in the right places.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference you can always directly specify a date by putting it into the DDMMMYYYY format wrapping it in ' and putting a d after it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 15 Feb 2014 20:08:33 GMT</pubDate>
    <dc:creator>overmar</dc:creator>
    <dc:date>2014-02-15T20:08:33Z</dc:date>
    <item>
      <title>How to change the number to date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174410#M264558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello every SAS users, here is a very simple question and i need your help!!&lt;/P&gt;&lt;P&gt;I want to let the records with T2DM=0 change its Diag_day to 01/01/1998.&lt;/P&gt;&lt;P&gt;But I meet some problem while programming it.&lt;/P&gt;&lt;P&gt;Can anyone help me solve the problem?&lt;/P&gt;&lt;P&gt;Thanks!!!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test4;&lt;/P&gt;&lt;P&gt;set test3;&lt;/P&gt;&lt;P&gt;if T2DM=0 then Diag_day_Q=19980101;&lt;/P&gt;&lt;P&gt;if T2DM=0 then Diag_day=mdy(substr(Diag_day_Q,5,2), substr(Diag_day_Q,7,2),substr(Diag_day_Q,1,4));&lt;/P&gt;&lt;P&gt;format Diag_day mmddyy10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16841:36&amp;nbsp;&amp;nbsp; 16841:60&amp;nbsp;&amp;nbsp; 16841:83&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16841:29&amp;nbsp;&amp;nbsp; 16841:53&amp;nbsp;&amp;nbsp; 16841:76&lt;/P&gt;&lt;P&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Each place is given by: (Number of times) at (Line):(Column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 183960 at 16841:25&lt;/P&gt;&lt;P&gt;NOTE: There were 386182 observations read from the data set WORK.TEST3.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEST4 has 386182 observations and 52 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.45 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.39 second&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 04:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174410#M264558</guid>
      <dc:creator>Willy</dc:creator>
      <dc:date>2014-02-14T04:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the number to date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174411#M264559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think this will work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test4;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format Diag_day date10.;&lt;/P&gt;&lt;P&gt;Diag_day_Q = 19980101;&lt;/P&gt;&lt;P&gt;Diag_day = mdy(substr(compress(Diag_day_Q),5,2), substr(compress(Diag_day_Q),7,2),substr(compress(Diag_day_Q),1,4));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 06:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174411#M264559</guid>
      <dc:creator>TarunKumar</dc:creator>
      <dc:date>2014-02-14T06:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the number to date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174412#M264560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try the below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test4;&lt;/P&gt;&lt;P&gt;set test3;&lt;/P&gt;&lt;P&gt;if T2DM=0 then Diag_day_Q=&lt;STRONG&gt;"19980101"&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if T2DM=0 then Diag_day=mdy(input(substr(Diag_day_Q,5,2),8.), input(substr(Diag_day_Q,7,2),8.), input(substr(Diag_day_Q,1,4),8.));&lt;/P&gt;&lt;P&gt;format Diag_day mmddyy10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the above, no notes in the log will be generated. Used character data in substr functions. Please check the &lt;STRONG&gt;Bold&lt;/STRONG&gt; letters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="816958" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Tried your code, we will get the output but with notes.&lt;/P&gt;&lt;P&gt;To avoid it, use the character data in substr and compress function, instead of the numeric data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 06:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174412#M264560</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2014-02-14T06:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the number to date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174413#M264561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems like a rather roundabout way to define a date, why not just write&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test4;&lt;/P&gt;&lt;P&gt;set test3;&lt;/P&gt;&lt;P&gt;if T2DM=0 then Diag_day='01JAN1998'd;&lt;/P&gt;&lt;P&gt;format Diag_day mmddyy10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially if T2DM is equal to 0 then diag_day is converted to the SAS date for 01/01/1998&lt;/P&gt;&lt;P&gt;Also this way you don't have to create an extra variable in Diag_day_Q which you likely will have to delete in the future, or have to make sure that your substr commands are all in the right places.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference you can always directly specify a date by putting it into the DDMMMYYYY format wrapping it in ' and putting a d after it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Feb 2014 20:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-the-number-to-date/m-p/174413#M264561</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-02-15T20:08:33Z</dc:date>
    </item>
  </channel>
</rss>

