<?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 How to change Date9. from numeric to character? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569651#M160558</link>
    <description>&lt;P&gt;Hi, I created some date variable using data step. But in the result dataset, those variables are shown as numeric rather than character. How can I switch them to character (and keep the format as Date9.)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let year = 2019;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data holiday;&lt;BR /&gt;nyd = mdy(1, 1, &amp;amp;year.); /*New Year's Day*/&lt;BR /&gt;format nyd date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;familyday = nwkdom(3, 2, 2, &amp;amp;year.); /*Family Day; 3rd Monday in February*/&lt;BR /&gt;format familyday date9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30605i02700E1E64689EC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jun 2019 21:57:01 GMT</pubDate>
    <dc:creator>newboy1218</dc:creator>
    <dc:date>2019-06-27T21:57:01Z</dc:date>
    <item>
      <title>How to change Date9. from numeric to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569651#M160558</link>
      <description>&lt;P&gt;Hi, I created some date variable using data step. But in the result dataset, those variables are shown as numeric rather than character. How can I switch them to character (and keep the format as Date9.)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let year = 2019;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data holiday;&lt;BR /&gt;nyd = mdy(1, 1, &amp;amp;year.); /*New Year's Day*/&lt;BR /&gt;format nyd date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;familyday = nwkdom(3, 2, 2, &amp;amp;year.); /*Family Day; 3rd Monday in February*/&lt;BR /&gt;format familyday date9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30605i02700E1E64689EC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 21:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569651#M160558</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-06-27T21:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to change Date9. from numeric to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569659#M160564</link>
      <description>&lt;P&gt;Please describe why you would actually want those variables to be character? The format should work anywhere people need to see it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;None of the functions for working with dates will work with character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot change a variable type once it is created.&lt;/P&gt;
&lt;P&gt;You could create a character variable as&lt;/P&gt;
&lt;PRE&gt;data holiday;
   nyd = mdy(1, 1, &amp;amp;year.); /*New Year's Day*/
   format nyd date9.;

   familyday = nwkdom(3, 2, 2, &amp;amp;year.); /*Family Day; 3rd Monday in February*/
   format familyday date9.;
   nydchar = put(nyd,date9.);
   familydaychar = put(familyday,date9.);
run;
&lt;/PRE&gt;
&lt;P&gt;Once you have the character value then you would not be able to apply a DATE9. format as that only works for numeric values.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 22:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569659#M160564</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-27T22:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to change Date9. from numeric to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569661#M160566</link>
      <description>&lt;P&gt;Why do you want a character variable?&lt;/P&gt;
&lt;P&gt;And if you do why in that style?&amp;nbsp; They will not sort right.&amp;nbsp; The first of december will be before the third of august.&lt;/P&gt;
&lt;P&gt;Use a format like YYMMDD10. instead. Then the values will sort properly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;nyd = put(mdy(1, 1, &amp;amp;year.),yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jun 2019 22:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569661#M160566</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-27T22:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to change Date9. from numeric to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569768#M160597</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 13:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-Date9-from-numeric-to-character/m-p/569768#M160597</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-06-28T13:07:01Z</dc:date>
    </item>
  </channel>
</rss>

