<?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: Data type conversion for Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497780#M132068</link>
    <description>&lt;P&gt;Renewal_date is a numeric variable.&amp;nbsp; It is a number of days since the cuttoff, regardless of what format is applied.&amp;nbsp; When you use the value here:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;tmp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;renewal_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2018"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your effectively saying&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;tmp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&amp;lt;a number of days since a date&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2018"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Which is invalid, you need to put() the numeric into text:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;tmp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(put(&lt;/SPAN&gt;renewal_date,date5.)&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2018"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remember numeric and text are different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please also close out previous questions on exactly the same topic!&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 12:08:58 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-09-21T12:08:58Z</dc:date>
    <item>
      <title>Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497772#M132064</link>
      <description>&lt;P&gt;Could you please help me understand why I'm getting missing values in 'tmp' variable? This is the extract of the big piece of a program, so my objective is to know why I;m getting&amp;nbsp;&lt;SPAN&gt;missing values in 'tmp'. What informat I should supply in input function&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format renewal_date date5.;
	renewal_date='09mar2018'd;
	output;
	renewal_date='09nov2018'd;
	output;
	renewal_date='19sep2018'd;
	output;
run;

data test1;
set test;
tmp=input(cats(renewal_date,"2018"),date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;Actual output:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;renewal_date &amp;nbsp;tmp&lt;BR /&gt;09MAR &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;09NOV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;19SEP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Desired Output:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;renewal_date &amp;nbsp; tmp&lt;BR /&gt;09MAR &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;09MAR 2018&lt;/SPAN&gt;&lt;BR /&gt;09NOV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;09NOV2018&lt;/SPAN&gt;&lt;BR /&gt;19SEP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19SEP2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 11:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497772#M132064</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-21T11:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497779#M132067</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format renewal_date date5.;
	renewal_date='09mar2018'd;
	output;
	renewal_date='09nov2018'd;
	output;
	renewal_date='19sep2018'd;
	output;
run;

data test1;
   set test;
   format renewal_date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Renewal_Date is already a numeric date variable, so no need to invoke character functions. Simply apply the appropriate format..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497779#M132067</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-09-21T12:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497780#M132068</link>
      <description>&lt;P&gt;Renewal_date is a numeric variable.&amp;nbsp; It is a number of days since the cuttoff, regardless of what format is applied.&amp;nbsp; When you use the value here:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;tmp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;renewal_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2018"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your effectively saying&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;tmp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&amp;lt;a number of days since a date&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2018"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Which is invalid, you need to put() the numeric into text:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;tmp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(put(&lt;/SPAN&gt;renewal_date,date5.)&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2018"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remember numeric and text are different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please also close out previous questions on exactly the same topic!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497780#M132068</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-21T12:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497781#M132069</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tmp=input(cats(vvalue(renewal_date),"2018"),date9.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497781#M132069</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-21T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497782#M132070</link>
      <description>&lt;P&gt;The CATS function tries to stick the text string 2018 at the end of your SAS date, which is a non-sensical thing to do. Your dates are already dates in 2018, and are SAS date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not really clear why you need TMP at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the actual output shown is from PROC PRINT (is it?), then you just need to change the format of renewal_date so you can see the year.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497782#M132070</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-21T12:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497788#M132074</link>
      <description>&lt;P&gt;I tried your code, but it is not producing the desired output as per Original Post. Output which I got is as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;renewal_date tmp&lt;BR /&gt;09MAR &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21252&lt;BR /&gt;09NOV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21497&lt;BR /&gt;19SEP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21446&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497788#M132074</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-21T12:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497790#M132075</link>
      <description>&lt;P&gt;yes I know. But it's not the objective in our master program. I gave only the extract of the code which I need date and month as character in order to concatenate year value.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497790#M132075</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-21T12:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497792#M132077</link>
      <description>TMP is a SAS date.  Give it a format like DATE9.</description>
      <pubDate>Fri, 21 Sep 2018 12:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497792#M132077</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-21T12:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497795#M132079</link>
      <description>&lt;P&gt;if I do it, I will get numeric variable for TMP where as required output should be in character.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497795#M132079</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-21T12:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497802#M132082</link>
      <description>&lt;P&gt;When you give it a DATE9. format, it will appear as characters&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in fact, you don't need TMP at all, as others have pointed out, all you need to do is to assign the DATE9. format to your variable named RENEWAL_DATE.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 13:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497802#M132082</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-21T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497833#M132102</link>
      <description>No, it is appearing as numeric. Appreciate if you could provide me the&lt;BR /&gt;example if you disagree with me.&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497833#M132102</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-21T14:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497849#M132113</link>
      <description>&lt;P&gt;If you need a character variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tmp = put(renewal_date, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497849#M132113</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-21T14:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Data type conversion for Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497856#M132118</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No, it is appearing as numeric. Appreciate if you could provide me the&lt;BR /&gt;example if you disagree with me.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When&amp;nbsp;TMP shows as numbers, it does not have a format assigned to it. This is a pretty basic concept being demonstrated here, you have not assigned a format to TMP. Assign a format to tmp and it will appear as characters. If it doesn't work, then show us your code.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 15:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-type-conversion-for-Date/m-p/497856#M132118</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-21T15:09:38Z</dc:date>
    </item>
  </channel>
</rss>

