<?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: 8. to date9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395404#M95348</link>
    <description>&lt;P&gt;yes it is a numeric, just i want to declare a variable to illustrate it.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2017 07:20:43 GMT</pubDate>
    <dc:creator>R_Chung</dc:creator>
    <dc:date>2017-09-13T07:20:43Z</dc:date>
    <item>
      <title>8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395402#M95346</link>
      <description>&lt;P&gt;I have searched many websites and get confused for a numeric date to date9. format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. 20170101 to&amp;nbsp;01JAN2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried many methods:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end_date_id = 20170101;
call symputx('end_date_id', input( put( end_date_id, yymmddn8.), date9.));
input( put( end_date_id, 8.), date9.);
end_date_id = input(put(datepart(end_date_id), yymmddn8.),date9.);
put end_date_id = date9.;
call symputx ('end_date_id', input(put(end_date_id, yymmddn8.),date9.));&lt;BR /&gt;*Seems this one work;&lt;BR /&gt;put(input(put(day_id, 8.),yymmdd8.), date9.)&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any sggestion to perform it easily and explain the logic to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 07:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395402#M95346</guid>
      <dc:creator>R_Chung</dc:creator>
      <dc:date>2017-09-13T07:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395403#M95347</link>
      <description>&lt;P&gt;I'm not sure I understand your question completely. You say that you have a date stored as a numeric variable, but you define end_date_id as a macro variable? Remember that a macro variable is merely text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 07:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395403#M95347</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-13T07:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395404#M95348</link>
      <description>&lt;P&gt;yes it is a numeric, just i want to declare a variable to illustrate it.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 07:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395404#M95348</guid>
      <dc:creator>R_Chung</dc:creator>
      <dc:date>2017-09-13T07:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395405#M95349</link>
      <description>&lt;P&gt;Ok. Use the INPUT and PUT functions like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	end_date_id = 20170101;
	dt=input(put(end_date_id, 8.), yymmdd8.);
	put dt date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 07:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395405#M95349</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-13T07:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395409#M95353</link>
      <description>&lt;P&gt;I suggest to read the &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lrcon&amp;amp;docsetTarget=p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&amp;amp;locale=en#" target="_self"&gt;doc about date and time values in SAS&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are also plenty of papers on the topic, for instance&amp;nbsp;&lt;A href="http://analytics.ncsu.edu/sesug/2008/HOW-063.pdf" target="_self"&gt;How to Read, Write, and Manipulate SAS ® Dates&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These informations will give you some background you can build on.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 07:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395409#M95353</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-09-13T07:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395427#M95370</link>
      <description>can I understand it as put(input(put(end_date_id, 8.), yymmdd8.), date9.)</description>
      <pubDate>Wed, 13 Sep 2017 08:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395427#M95370</guid>
      <dc:creator>R_Chung</dc:creator>
      <dc:date>2017-09-13T08:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395465#M95389</link>
      <description>&lt;P&gt;Just because you put digits into a macro variable doesn't make it numeric. &amp;nbsp;How SAS interprets it depends on the context. &amp;nbsp;For example, this simplified variation would work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let end_date_id = 20170101;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then later:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx('end_date_id', put( input("&amp;amp;end_date_id", yymmdd8.), date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a DATA step double quotes around the macro variable reference lets it resolve, yet lets the DATA step treat it as a character string. &amp;nbsp;That lets you remove one function from the equation. &amp;nbsp;So the INPUT function converts the string to the proper date value, and the PUT function expresses the result in the proper format.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 10:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395465#M95389</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-13T10:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395844#M95536</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; &amp;amp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;BR /&gt;This is what I am exactly doing.</description>
      <pubDate>Thu, 14 Sep 2017 03:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395844#M95536</guid>
      <dc:creator>R_Chung</dc:creator>
      <dc:date>2017-09-14T03:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: 8. to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395847#M95537</link>
      <description>&lt;P&gt;If you want to work just in macro code then you can use %SYSFUNC() to call the INPUTN() function to convert your digits into a date. You can also add a FORMAT to the %SYSFUNC() call to format the string that it returns.&lt;/P&gt;
&lt;P&gt;So for example here are ways to convert your digits into an actual SAS date value, a SAS date formatted using the DATE9 format and also a date literal. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date_digits = 20170101;
%let actual_date=%sysfunc(inputn(&amp;amp;date_digits,yymmdd8));
%let date9_string=%sysfunc(inputn(&amp;amp;date_digits,yymmdd8),date9);
%let date_literal="%sysfunc(inputn(&amp;amp;date_digits,yymmdd8),date9)"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could use &amp;amp;actual_date or &amp;amp;date_literal in SAS code directly or you could use &amp;amp;date9_string to generate a date literal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where date=&amp;amp;actual_date
where date=&amp;amp;date_literal
where date="&amp;amp;date9_string"d &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Sep 2017 03:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/8-to-date9/m-p/395847#M95537</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-14T03:36:17Z</dc:date>
    </item>
  </channel>
</rss>

