<?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 Datetime variable to numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664259#M22848</link>
    <description>Hi Kurt, Thanks for your help and suggestions. So what should I do if&lt;BR /&gt;I need to compare it to another date which is stored in the same&lt;BR /&gt;format (19700201)?&lt;BR /&gt;If I have understood correctly, your solution is to convert both dates&lt;BR /&gt;into SAS dates and then compare them?&lt;BR /&gt;</description>
    <pubDate>Tue, 23 Jun 2020 12:36:11 GMT</pubDate>
    <dc:creator>salvavit</dc:creator>
    <dc:date>2020-06-23T12:36:11Z</dc:date>
    <item>
      <title>Convert Datetime variable to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664251#M22846</link>
      <description>&lt;P&gt;Hi all, I have a list of Datetime values (e.g.&amp;nbsp;02JAN1970:01:00:02) that I want to convert into numerical having the following format: 19700102&lt;/P&gt;&lt;P&gt;I have wrote the following code, but it ends up showing a list of dots instead of the actual dates.&lt;/P&gt;&lt;PRE&gt;data table_2;
set table_1;
day_p = datepart(day_p);
format day_p yymmddn8.;
run;

data table_3; 
set table_2; 
day_p = input(put(input(day_p,date9.),yymmddn8.),8.);
format day_p 8.;
run;&lt;/PRE&gt;&lt;P&gt;May anyone help me in solving this issue?&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 12:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664251#M22846</guid>
      <dc:creator>salvavit</dc:creator>
      <dc:date>2020-06-23T12:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime variable to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664256#M22847</link>
      <description>&lt;P&gt;You have an INPUT() too many:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
dt = "02JAN1970:01:00:02"dt; 
day_p = datepart(dt);
day_n = input(put(day_p,yymmddn8.),8.);
format
  dt datetime19.
  day_p yymmddd10.
  day_n 8.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Be advised that the result is not useful for anything. You can't use it in calculations, cannot display it nicely, and can't use the gazillion goodies that SAS provides for handling dates. It needs more bytes than a SAS date (which can be stored with 4) on top.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 12:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664256#M22847</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T12:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime variable to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664259#M22848</link>
      <description>Hi Kurt, Thanks for your help and suggestions. So what should I do if&lt;BR /&gt;I need to compare it to another date which is stored in the same&lt;BR /&gt;format (19700201)?&lt;BR /&gt;If I have understood correctly, your solution is to convert both dates&lt;BR /&gt;into SAS dates and then compare them?&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jun 2020 12:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664259#M22848</guid>
      <dc:creator>salvavit</dc:creator>
      <dc:date>2020-06-23T12:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime variable to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664272#M22850</link>
      <description>&lt;P&gt;Absolutely. Anything that is a date, time or datetime value should be stored as such in SAS. Even things that show only periods (year/month) should be stored as a date (1st of month) with a format that shows year/month only, like yymmd7. Because then you can still use functions to calculate intervals etc.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 13:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Datetime-variable-to-numeric/m-p/664272#M22850</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T13:28:19Z</dc:date>
    </item>
  </channel>
</rss>

