<?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: Create a new date variable from a timestamp &amp;quot;2021-10-08 12:02:42&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794414#M254730</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Good catch &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Feb 2022 07:20:29 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-02-04T07:20:29Z</dc:date>
    <item>
      <title>Create a new date variable from a timestamp "2021-10-08 12:02:42"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794342#M254702</link>
      <description>&lt;P&gt;I'm trying to create a new variable&amp;nbsp;(i.e., a date,&amp;nbsp; numeric) from an existing variable (i.e., a timestamp, character). I can use the SUBSTR function to pull out the date from the timestamp, but I can't figure out the next step.&lt;/P&gt;
&lt;PRE&gt;DATA new;
	SET old;
	date=SUBSTR(informed_consent_hip_v_0, 1, 10);
RUN;&lt;/PRE&gt;
&lt;P&gt;The timestamp values follow this format: "2021-10-08 12:02:42"&lt;/P&gt;
&lt;P&gt;After using the SUBSTR function, the value of "date" is "2021-10-08".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I convert "2021-10-08" to a SAS date? Will it automatically convert it to a numeric variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794342#M254702</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-02-03T20:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new date variable from a timestamp "2021-10-08 12:02:42"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794343#M254703</link>
      <description>&lt;P&gt;Use the Input Function like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _null_;
	dt = "2021-10-08 12:02:42";
	date = input(substr(dt, 1, 10), yymmdd10.);
	put date = date9.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794343#M254703</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-03T20:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new date variable from a timestamp "2021-10-08 12:02:42"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794346#M254705</link>
      <description>&lt;P&gt;Actually don't even need the substring. The Informat will use the number of characters you specify:&lt;/P&gt;
&lt;PRE&gt;      

DATA _null_;
	dt = "2021-10-08 12:02:42";
	date = input(dt, yymmdd10.);
	put date = date9.;
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794346#M254705</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-03T20:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new date variable from a timestamp "2021-10-08 12:02:42"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794354#M254708</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want;
	dt = "2021-10-08 12:02:42";
	datetime = input(dt, anydtdtm.);
	date = datepart(datetime);
	put date = date9. datetime = datetime22.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One other option - read in as datetime and parse out the date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794354#M254708</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-03T20:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new date variable from a timestamp "2021-10-08 12:02:42"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794414#M254730</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Good catch &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 07:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-date-variable-from-a-timestamp-quot-2021-10-08-12/m-p/794414#M254730</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-04T07:20:29Z</dc:date>
    </item>
  </channel>
</rss>

