<?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: Change date format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712050#M26986</link>
    <description>&lt;P&gt;Then yes. Simply do like below. I just created three obs for demonstration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dt $20.;
datalines;
2020-12-28 07:40:00
2020-12-29 07:40:00
2020-12-30 07:40:00
;

data want;
   set have;
   dtnum    = input(dt, anydtdtm19.);
   datepart = datepart(dtnum);
   format dtnum datetime20. datepart ddmmyy10.;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Jan 2021 09:16:31 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-01-18T09:16:31Z</dc:date>
    <item>
      <title>Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712038#M26980</link>
      <description>&lt;P&gt;Hi I have reading a CSV file in SAs, and the CSv file has this date format:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;2020-12-30 07:40:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It says it has a format $21, character when I click on the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to make a statment in a datastep where I only have the dates from the today()-3 and today()-9&lt;/P&gt;
&lt;P&gt;or data between 2021-01-10 and 2021-01-16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how can I do that with this kind of format&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 08:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712038#M26980</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T08:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712040#M26981</link>
      <description>&lt;P&gt;How did you import the CSV file? If you do so with a data step and the infile statement, you can specify exactly how the variable should be read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, a quick fix would be to use the input function and convert the character datetime to a numeric SAS Datetime variable and find the date part like this. Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   dt       = "2020-12-30 07:40:00";
   dtnum    = input(dt, anydtdtm19.);
   datepart = datepart(dtnum);
   format dtnum datetime20. datepart ddmmyy10.;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2021 08:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712040#M26981</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-18T08:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712046#M26983</link>
      <description>&lt;P&gt;I have a 1000 different date in that format, will it change them all with this code? :9&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712046#M26983</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T09:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712047#M26984</link>
      <description>&lt;P&gt;Do you have 1000 date variables or 1000 observations with date values stored as character?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712047#M26984</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-18T09:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712048#M26985</link>
      <description>&lt;P&gt;I have one variable of dates but ,many observations&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712048#M26985</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T09:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712050#M26986</link>
      <description>&lt;P&gt;Then yes. Simply do like below. I just created three obs for demonstration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dt $20.;
datalines;
2020-12-28 07:40:00
2020-12-29 07:40:00
2020-12-30 07:40:00
;

data want;
   set have;
   dtnum    = input(dt, anydtdtm19.);
   datepart = datepart(dtnum);
   format dtnum datetime20. datepart ddmmyy10.;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712050#M26986</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-18T09:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712051#M26987</link>
      <description>&lt;P&gt;Thank you is it possible to make a statment&lt;/P&gt;
&lt;P&gt;where it only outputs dates from the today()-8 which is the 10th january to today()-3 which is te 16th january&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712051#M26987</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T09:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712054#M26988</link>
      <description>&lt;P&gt;One could argue that today() - 3 was the 15. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, yes do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dt $20.;
datalines;
2020-12-28 07:40:00
2020-12-29 07:40:00
2020-12-30 07:40:00
2020-12-31 07:40:00
2021-01-01 07:40:00
2021-01-02 07:40:00
2021-01-03 07:40:00
2021-01-04 07:40:00
2021-01-05 07:40:00
2021-01-06 07:40:00
2021-01-07 07:40:00
2021-01-08 07:40:00
2021-01-09 07:40:00
2021-01-10 07:40:00
2021-01-11 07:40:00
2021-01-12 07:40:00
2021-01-13 07:40:00
2021-01-14 07:40:00
2021-01-15 07:40:00
2021-01-16 07:40:00
2021-01-17 07:40:00
2021-01-18 07:40:00
;

data want;
   set have;
   dtnum    = input(dt, anydtdtm19.);
   datepart = datepart(dtnum);

   if today()-8 &amp;lt;= datepart &amp;lt;= today()-3;

   format dtnum datetime20. datepart ddmmyy10.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt                   dtnum               datepart 
2021-01-10 07:40:00  10JAN2021:07:40:00  10/01/2021 
2021-01-11 07:40:00  11JAN2021:07:40:00  11/01/2021 
2021-01-12 07:40:00  12JAN2021:07:40:00  12/01/2021 
2021-01-13 07:40:00  13JAN2021:07:40:00  13/01/2021 
2021-01-14 07:40:00  14JAN2021:07:40:00  14/01/2021 
2021-01-15 07:40:00  15JAN2021:07:40:00  15/01/2021 &lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712054#M26988</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-18T09:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712055#M26989</link>
      <description>&lt;P&gt;A simple condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where today() - 8 le date le today() - 3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;either as part of a SQL SELECT, or as statement in a data step.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 09:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712055#M26989</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-18T09:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Change date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712082#M26992</link>
      <description>&lt;P&gt;Thanks erveryone :9&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 11:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-date-format/m-p/712082#M26992</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T11:56:43Z</dc:date>
    </item>
  </channel>
</rss>

