<?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: Dates = numbers? HOW in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102483#M28693</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you have posted some sample data it would have helped...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input date $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;30102011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;newdate=input(date,ddmmyy8.);&lt;/P&gt;&lt;P&gt;format newdate date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Jul 2012 04:43:54 GMT</pubDate>
    <dc:creator>shivas</dc:creator>
    <dc:date>2012-07-09T04:43:54Z</dc:date>
    <item>
      <title>Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102482#M28692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had dates in the format: DD/MM/YYYY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted these to be represented as numbers. So I did:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have; set have;&lt;/P&gt;&lt;P&gt;date2= date*1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This command produced large negative numbers. No decipherable ddmmyyy was found (im looking for numeric dates without the commars).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then, performed the following command:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 115%; color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; have;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; have;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; date &lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;ddmmyyn8.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;STRONG style="line-height: 115%; color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This produced a pleasing result in the form of ddmmyyyy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But however SAS still didnt recognise my date as numeric. When I multipled by 1, I still received large negative numbers. How do I solve this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need ddmmyyyy to be in number form in order fo this command to work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data have&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;IF &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;DATE&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;MMYY = substr(DATE, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;7&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;RUN&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 04:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102482#M28692</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-07-09T04:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102483#M28693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you have posted some sample data it would have helped...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input date $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;30102011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;newdate=input(date,ddmmyy8.);&lt;/P&gt;&lt;P&gt;format newdate date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 04:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102483#M28693</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-07-09T04:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102484#M28694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmm i follwed your codes but didnt seem to work. I received an error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you could help me identify what im doing wrong that would be rlly helpful. Here is my data:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 08:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102484#M28694</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-07-09T08:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102485#M28695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your file is dbf file and the date variable has already been numberic after importing SAS and its formate is not DDMMYY but MMDDYY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;proc import datafile='c:\test.dbf' out=have dbms=dbf replace;run;
data want;
 set have;
 mmyy=put(date,mmyys.);
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 08:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102485#M28695</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-07-09T08:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102486#M28696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey thanks for your input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT In my dataset would like dates to be numbers and without the '/'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To illustrate: if the date was 31/12/2011 I would like it to be 31122011.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if I multiply 31122011 by 1 it should still be 31122011.&amp;nbsp;&amp;nbsp; Not a large negative number (I commonly find I can't plus or minus numbers to the date formats)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 09:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102486#M28696</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-07-09T09:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102487#M28697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I dont understand the logic why you want the date in this format 31122011 .Any how you can just apply the format like this..SAS internally stores date values in numbers itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;set dbf;&lt;/P&gt;&lt;P&gt;date1=date*1;&lt;/P&gt;&lt;P&gt;format date1 mmddyy7.;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 09:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102487#M28697</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-07-09T09:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102488#M28698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I would like the date in the numeric format because then I can plus ten years to the year or minus ten years to the year. I'm looking to edit my dates later on my in my analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Via your method date 1 still is not recognised as a number. When you multiply by 1 or minus 1 I am still receiving a large negative. Furthermore, is it possible to have it in the format ddmmyyyy OR yyyymmdd?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 09:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102488#M28698</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-07-09T09:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102489#M28699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Date values are stored as the number of days since 1/1/1960 in SAS and displayed with date formats like mmddyys10. (MM/DD/YYYY)/date9.(DDMONYYYY), etc.&lt;/P&gt;&lt;P&gt;SAS has specific functions to do date arithmetic like increment/decrement dates by week/month/quarter/year or count the date intervals between two dates.&lt;/P&gt;&lt;P&gt;For some examples/details, please see Art Carpenter's paper on using SAS dates and times &lt;A href="http://www.lexjansen.com/pharmasug/2005/tutorials/tu01.pdf" title="http://www.lexjansen.com/pharmasug/2005/tutorials/tu01.pdf"&gt;http://www.lexjansen.com/pharmasug/2005/tutorials/tu01.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code snippet will turn a date value 31/12/2012 into an integer value of 31122012.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date = '31Dec2012'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; newdate = INPUT(PUT(x,ddmmyyn8.),best12.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put newdate=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 10:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102489#M28699</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-07-09T10:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102490#M28700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using this method I only have 1 observation. I have attached my data above. What can I change '31dec2012' to read all my data not just 1?&lt;IMG alt="Capture.JPG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/2219_Capture.JPG" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 14:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102490#M28700</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-07-09T14:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102491#M28701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about combine code from Ksharp and Alpay?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc import datafile='c:\temp\test.dbf' out=have dbms=dbf replace;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; newdate = INPUT(PUT(date,ddmmyyn8.),best12.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 14:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102491#M28701</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-09T14:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dates = numbers? HOW</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102492#M28702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Once you understand how SAS stores date values, this would be the way to add 10 years:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; newdate = intnx('year', date, +10, 'same');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date newdate ddmmyyn8.;&amp;nbsp; /* or any other date format you would like to see */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But first, it is important to understand SAS's date scale.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2012 14:43:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dates-numbers-HOW/m-p/102492#M28702</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-09T14:43:44Z</dc:date>
    </item>
  </channel>
</rss>

