<?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: How to get date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747851#M234807</link>
    <description>&lt;P&gt;I'm not completely sure what you need.&amp;nbsp; Do you want a formatted SAS date or a standardized character date?&amp;nbsp; Here are some results, immediately below.&amp;nbsp; Are any of these columns what you need? The program that produced them is below.&amp;nbsp; By the way, there is no 31st day of June, so SAS is producing a missing value for 2015-06-31.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1623688937403.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60365iA243F48611EB7EE9/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1623688937403.png" alt="jimbarbour_0-1623688937403.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
	length Input_Date	$15;
	FORMAT	SAS_Date  DATE11.;
	input Input_Date	$;

	SAS_Date			=	INPUT(Input_Date, ANYDTDTE11.);

	Formatted_Date		=	CATS(SUBSTR(vvalue(SAS_Date), 8, 4), LOWCASE(SUBSTR(vvalue(SAS_Date), 3, 5)),  SUBSTR(vvalue(SAS_Date), 1, 2));

cards;
2014-may-31
2015-06-31
2014-07-14
2021-jun-21
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jun 2021 16:44:15 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2021-06-14T16:44:15Z</dc:date>
    <item>
      <title>How to get date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747849#M234806</link>
      <description>&lt;P&gt;data dt;&lt;BR /&gt;length date$ 15;&lt;BR /&gt;input date;&lt;BR /&gt;cards;&lt;BR /&gt;2014-may-31&lt;BR /&gt;2015-06-31`&lt;BR /&gt;2014-07-14&lt;BR /&gt;2021-jun-21&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need dates like&lt;BR /&gt;2014-may-31&lt;/P&gt;&lt;P&gt;2015-jun-31&lt;/P&gt;&lt;P&gt;2014-Aug-14&lt;/P&gt;&lt;P&gt;2021-jun-21&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there anyway to get dates like this. Can anyone help me to do this job&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 15:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747849#M234806</guid>
      <dc:creator>sasuser123123</dc:creator>
      <dc:date>2021-06-14T15:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747851#M234807</link>
      <description>&lt;P&gt;I'm not completely sure what you need.&amp;nbsp; Do you want a formatted SAS date or a standardized character date?&amp;nbsp; Here are some results, immediately below.&amp;nbsp; Are any of these columns what you need? The program that produced them is below.&amp;nbsp; By the way, there is no 31st day of June, so SAS is producing a missing value for 2015-06-31.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1623688937403.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60365iA243F48611EB7EE9/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1623688937403.png" alt="jimbarbour_0-1623688937403.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
	length Input_Date	$15;
	FORMAT	SAS_Date  DATE11.;
	input Input_Date	$;

	SAS_Date			=	INPUT(Input_Date, ANYDTDTE11.);

	Formatted_Date		=	CATS(SUBSTR(vvalue(SAS_Date), 8, 4), LOWCASE(SUBSTR(vvalue(SAS_Date), 3, 5)),  SUBSTR(vvalue(SAS_Date), 1, 2));

cards;
2014-may-31
2015-06-31
2014-07-14
2021-jun-21
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 16:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747851#M234807</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-06-14T16:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to get date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747854#M234809</link>
      <description>&lt;P&gt;As far as I know, there is no preprogrammed format YYYY-mon-dd. You could certainly create your own &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p0n990vq8gxca6n1vnsracr6jp2c.htm#p0eubpiv9ngaocn1uatbigc5swi2" target="_self"&gt;custom format in PROC FORMAT&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can read your data as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
input date  :anydtdte12.;
format date date9.;
cards;
2014-may-31
2015-06-30
2014-07-14
2021-jun-21
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note that I have changed your data line 2015-06-31` to remove the unnecessary character, and because there are not 31 days in June.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 16:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747854#M234809</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-14T16:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747857#M234811</link>
      <description>&lt;P&gt;This mostly works:&lt;/P&gt;
&lt;PRE&gt;proc format;
picture customdate (default=11)
low-high = '%Y-%3B-%0d'   ( datatype=date);
run;

data dt;
informat date anydtdte.;
format date customdate.;
input date;
cards;
2014-may-31
2015-06-31`
2014-07-14
2021-jun-21
;
run;&lt;/PRE&gt;
&lt;P&gt;Your desired appearance is not a standard date layout from what I see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, June NEVER has 31 days so your value of 2015-06-31 is an invalid date and you need to decide what value it should be.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 16:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747857#M234811</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-14T16:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747858#M234812</link>
      <description>&lt;P&gt;When you import your date, you can specify an informat. This tells SAS what format the data should be read in as. The format then controls how it's displayed.&lt;/P&gt;
&lt;P&gt;To fix it while reading in: (Note that June 31 is an invalid date so SAS will not create that date).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
informat date anydtdte.;
format date date11.;
input date;
cards;
2014-may-31
2015-06-31
2014-07-14
2021-jun-21
;
run;

proc print data =dt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need to convert it after the fact, this is what you'd use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set dt;
date_num = input(date, anydtdte12.);
format date_num date11.;
run;

proc print data=want;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282134"&gt;@sasuser123123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data dt;&lt;BR /&gt;length date$ 15;&lt;BR /&gt;input date;&lt;BR /&gt;cards;&lt;BR /&gt;2014-may-31&lt;BR /&gt;2015-06-31`&lt;BR /&gt;2014-07-14&lt;BR /&gt;2021-jun-21&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need dates like&lt;BR /&gt;2014-may-31&lt;/P&gt;
&lt;P&gt;2015-jun-31&lt;/P&gt;
&lt;P&gt;2014-Aug-14&lt;/P&gt;
&lt;P&gt;2021-jun-21&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there anyway to get dates like this. Can anyone help me to do this job&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 16:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-date/m-p/747858#M234812</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-14T16:04:50Z</dc:date>
    </item>
  </channel>
</rss>

