<?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: Convert SAS date to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633806#M188046</link>
    <description>&lt;P&gt;Thanks .Can you please let me know if the following are correct?&lt;/P&gt;
&lt;P&gt;What will be the code if the desired numeric value is 28102019?&lt;/P&gt;
&lt;P&gt;Number_date= input(put(SAS_Date,DDMMYYn8.),8.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What will be the code if the desired numeric value is 1910?&lt;/P&gt;
&lt;P&gt;Number_date= input(put(SAS_Date,YYMMN4.),4.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please explain what each statement is doing?&lt;/P&gt;
&lt;P&gt;step1:put(SAS_Date,yymmddn8.)&lt;/P&gt;
&lt;P&gt;Step2:input(Result of 1st step,8.)&lt;/P&gt;</description>
    <pubDate>Sat, 21 Mar 2020 10:44:23 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-03-21T10:44:23Z</dc:date>
    <item>
      <title>Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633804#M188044</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to convert SAS date to number (numeric).&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;SASDate=’28OCT2019’d;&lt;/P&gt;
&lt;P&gt;NumberDate will be 20191028 (number)&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633804#M188044</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-03-21T10:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633805#M188045</link>
      <description>&lt;P&gt;There you go&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   SASDate='28OCT2019'd;
   n=input(put(SASDate, yymmddn8.), 8.);
   put n=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633805#M188045</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-21T10:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633806#M188046</link>
      <description>&lt;P&gt;Thanks .Can you please let me know if the following are correct?&lt;/P&gt;
&lt;P&gt;What will be the code if the desired numeric value is 28102019?&lt;/P&gt;
&lt;P&gt;Number_date= input(put(SAS_Date,DDMMYYn8.),8.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What will be the code if the desired numeric value is 1910?&lt;/P&gt;
&lt;P&gt;Number_date= input(put(SAS_Date,YYMMN4.),4.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please explain what each statement is doing?&lt;/P&gt;
&lt;P&gt;step1:put(SAS_Date,yymmddn8.)&lt;/P&gt;
&lt;P&gt;Step2:input(Result of 1st step,8.)&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633806#M188046</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-03-21T10:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633807#M188047</link>
      <description>&lt;P&gt;While &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; has provided the answer, there is really no value in SAS to have a numeric 20191028. You can't do anything with this numeric value (except things that would be harder to do than if you left it as ’28OCT2019’d). SAS has built lots of functions to handle ’28OCT2019’d, but if you want to do anything with a numeric 20191028, you have to create your own functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if you want a character 20191028 for specific output needs, that's understandable and easy to produce; but a numeric 20191028 is just making your future coding harder.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633807#M188047</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-21T10:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633809#M188048</link>
      <description>&lt;P&gt;Simply change the format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   SASDate='28OCT2019'd;
   n=input(put(SASDate, ddmmyyn8.), 8.);
   put n=;
run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0mlfb88dkhbmun1x08qbh5xbs7e.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;The Put Function&lt;/A&gt; returns the date value in a character string specified by the format ddmmyyn8 ''28102019"&lt;/P&gt;
&lt;P&gt;2: &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p19en16vskd2vhn1vwmxpxnglxxs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;The Input Function&lt;/A&gt;&amp;nbsp;reads the character string from above and returns it as the number&amp;nbsp;&amp;nbsp;28102019 using the 8. informat.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633809#M188048</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-21T10:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633811#M188049</link>
      <description>&lt;P&gt;Again, change the format..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   SASDate='28OCT2019'd;
   n=input(put(SASDate, yymmn4.), 8.);
   put n=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, I very much agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633811#M188049</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-21T10:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633812#M188050</link>
      <description>&lt;P&gt;Should it be 8. or 4. ???&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 10:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633812#M188050</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-03-21T10:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633813#M188051</link>
      <description>&lt;P&gt;I will summarize the examples of converting SAS date to numeric number:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#FF0000"&gt;Example 1:&lt;/FONT&gt;
SAS_Date=’28OCT2019’d;
Desired numeric is 20191028
Number_date= input(put(SAS_Date,yymmddn8.),8.);
Put Function returns the date value in a character specified by the format yymmddn8.''20191028"
Input Function reads the character from above and returns it as the number  20191028 using the 8. informat
&lt;FONT color="#FF0000"&gt;Example 2:&lt;/FONT&gt;
SAS_Date=’28OCT2019’d;
Desired numeric is 28102019
Number_date= input(put(SAS_Date,DDMMYYn8.),8.);
Put Function returns the date value in a character specified by the format DDMMYYn8. ,''28102019"
Input Function reads the character from above and returns it as the number  28102019  using the 8. informat
&lt;FONT color="#FF0000"&gt;Example 3:&lt;/FONT&gt;
SAS_Date=’28OCT2019’d;
Desired numeric is 1910
Number_date= input(put(SAS_Date,YYMMN4.),4.);
Put Function returns the date value in a character specified by the format YYMMn4. ,''1910"
Input Function reads the character from above and returns it as the number  1910  using the 4. informat
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 11:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633813#M188051</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-03-21T11:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633919#M188110</link>
      <description>&lt;P&gt;And I see no advantage to having multiple non-date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the date value I USE the value in any of those formats by using the appropriate format for grouping for reporting, analysis or graphing purposes. Showing the ability to create additional numeric variables does not show the utility of having that multiplicity of variables. For graphing they are BAD as the interval between tick marks by default is going to be way off. Graph something with an x-axis that uses your "numeric" date values similar to 20100320 that crosses a couple of year boundaries and see just how bat that is. For analysis such as a time-series they won't work at all as I expect SAS procs like Arima to throw errors about improper intervals. For regression where the values should have the same interval between 20101231 and 20110101 and 20110102 they won't.&amp;nbsp; I also believed that in the past you have asked a lot of questions dealing with numeric "dates" of the yymm version. And a great deal of the solutions started with creating actual SAS date values to allow calculation of intervals or comparing offset dates.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 04:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date-to-numeric/m-p/633919#M188110</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-22T04:46:26Z</dc:date>
    </item>
  </channel>
</rss>

