<?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: coverting date into a char (or int) with the same look in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591703#M169559</link>
    <description>&lt;P&gt;Why? It's much better to store dates as SAS Date values and not as strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a put function with a format to write a numerical value as a string. You then assign the result of this to a new variable of type character.&lt;/P&gt;
&lt;PRE&gt;date_string_var=put(sasdate_var, yymmn4.);&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Sep 2019 21:00:45 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-09-25T21:00:45Z</dc:date>
    <item>
      <title>coverting date into a char (or int) with the same look</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591699#M169555</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me with the following formatting change ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date column (format yynnm4.&amp;nbsp;&amp;nbsp;&amp;nbsp; for example 1803 representing 2018 March)&lt;/P&gt;&lt;P&gt;I want to create the exact same column but as text ( for example text 1803, or as an integer 1803).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 20:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591699#M169555</guid>
      <dc:creator>akosyan</dc:creator>
      <dc:date>2019-09-25T20:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: coverting date into a char (or int) with the same look</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591701#M169557</link>
      <description>&lt;P&gt;Depending on what you mean by "exact same column".&lt;/P&gt;
&lt;P&gt;A new variable with the character value can be done with:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   datechar = put(date,yymmn4.);
run;&lt;/PRE&gt;
&lt;P&gt;I believe your description confused the M and N in the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you mean to change the existing variable you can't directly. Once a variable is created the type is fixed. You would have to rename your existing variable and create a variable with the same name using similar code:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have (rename=(date=olddate);
   date = put(olddate,yynnm4.);
   drop olddate;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2019 20:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591701#M169557</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-25T20:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: coverting date into a char (or int) with the same look</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591702#M169558</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length crdate $4;
crdate = put(numdate,yymmn4.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you just use the display format in a put() function.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 20:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591702#M169558</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-25T20:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: coverting date into a char (or int) with the same look</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591703#M169559</link>
      <description>&lt;P&gt;Why? It's much better to store dates as SAS Date values and not as strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a put function with a format to write a numerical value as a string. You then assign the result of this to a new variable of type character.&lt;/P&gt;
&lt;PRE&gt;date_string_var=put(sasdate_var, yymmn4.);&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2019 21:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591703#M169559</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-25T21:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: coverting date into a char (or int) with the same look</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591704#M169560</link>
      <description>&lt;P&gt;Thanks all, this worked !!!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 21:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coverting-date-into-a-char-or-int-with-the-same-look/m-p/591704#M169560</guid>
      <dc:creator>akosyan</dc:creator>
      <dc:date>2019-09-25T21:04:28Z</dc:date>
    </item>
  </channel>
</rss>

