<?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 change date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776499#M246980</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401093"&gt;@Gieorgie&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401093"&gt;@Gieorgie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like to change the date format to the picture below 2021-01 (...)&lt;/P&gt;
&lt;PRE&gt;PROC SQL;     
create table PolisyEnd as 
    select distinct  
  ,datepart(t1.PRP_END_DATE) as PRP_END_DATE format yymmdd10.
	,datepart(t1.PRP_END_DATE) as POLICY_VINTAGE format YYMM&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;w&lt;/FONT&gt;&lt;/STRONG&gt;.,&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n1k45hxg0vxohqn1ktr8k1tnmrn1.htm" target="_blank" rel="noopener"&gt;YYMM&lt;STRONG&gt;&lt;FONT color="#008000"&gt;D&lt;/FONT&gt;&lt;/STRONG&gt;. format&lt;/A&gt;. (The "&lt;EM&gt;w&lt;/EM&gt;" in "&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p0fb4qveq3tmudn1bgdbhlpq9kto.htm" target="_blank" rel="noopener"&gt;YYMM&lt;EM&gt;w&lt;/EM&gt;.&lt;/A&gt;" is just a place holder for the &lt;EM&gt;w&lt;/EM&gt;idth specification as in &lt;FONT face="courier new,courier"&gt;YYMM&lt;STRONG&gt;7&lt;/STRONG&gt;.&lt;/FONT&gt;.)&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 14:23:54 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-10-26T14:23:54Z</dc:date>
    <item>
      <title>How to change date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776484#M246975</link>
      <description>&lt;P&gt;I would like to change the date format to the picture below 2021-01 eg I found in the documentation that it is YYMMw. However, when he tries to format, he gets this result.&lt;/P&gt;
&lt;P&gt;When i tried use subtr like this:&lt;/P&gt;
&lt;PRE&gt;    ,input(substr(t1.PRP_END_DATE,1,4)||'-'||substr(t1.PRP_END_DATE,5,2),yymmdd10.)		as POLICY_VINTAGE,
&lt;/PRE&gt;
&lt;P&gt;i got error :ERROR: Function SUBSTR requires a character expression as argument 1.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_0-1635255702740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65035i7A62780940CF48D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_0-1635255702740.png" alt="Gieorgie_0-1635255702740.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This my result :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_1-1635255745884.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65036i79BDD23ACA9AB216/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_1-1635255745884.png" alt="Gieorgie_1-1635255745884.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And this is my code:&lt;/P&gt;
&lt;PRE&gt;PROC SQL;     
create table PolisyEnd as 
    select distinct  
  ,datepart(t1.PRP_END_DATE) as PRP_END_DATE format yymmdd10.
	,datepart(t1.PRP_END_DATE) as POLICY_VINTAGE format YYMMw.,&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 13:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776484#M246975</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-26T13:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to change date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776499#M246980</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401093"&gt;@Gieorgie&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401093"&gt;@Gieorgie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like to change the date format to the picture below 2021-01 (...)&lt;/P&gt;
&lt;PRE&gt;PROC SQL;     
create table PolisyEnd as 
    select distinct  
  ,datepart(t1.PRP_END_DATE) as PRP_END_DATE format yymmdd10.
	,datepart(t1.PRP_END_DATE) as POLICY_VINTAGE format YYMM&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;w&lt;/FONT&gt;&lt;/STRONG&gt;.,&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n1k45hxg0vxohqn1ktr8k1tnmrn1.htm" target="_blank" rel="noopener"&gt;YYMM&lt;STRONG&gt;&lt;FONT color="#008000"&gt;D&lt;/FONT&gt;&lt;/STRONG&gt;. format&lt;/A&gt;. (The "&lt;EM&gt;w&lt;/EM&gt;" in "&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p0fb4qveq3tmudn1bgdbhlpq9kto.htm" target="_blank" rel="noopener"&gt;YYMM&lt;EM&gt;w&lt;/EM&gt;.&lt;/A&gt;" is just a place holder for the &lt;EM&gt;w&lt;/EM&gt;idth specification as in &lt;FONT face="courier new,courier"&gt;YYMM&lt;STRONG&gt;7&lt;/STRONG&gt;.&lt;/FONT&gt;.)&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 14:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776499#M246980</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-10-26T14:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to change date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776513#M246982</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401093"&gt;@Gieorgie&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We're trying to help you, so please help us. From now on do not show us error messages detached from the code. Please do show us the complete log, so we can see the code and the error message on the next line. Please also format the log properly, by copying the log as text and then pasting it into the window that appears when you click on the &amp;lt;/&amp;gt; icon here in the SAS communities.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 14:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776513#M246982</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-26T14:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to change date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776520#M246986</link>
      <description>&lt;P&gt;If you have a date, time, or datetime value then usually the easiest way to get a piece of the value is an appropriate date or time function. If you have a datetime value and want date elements then use the Datepart function to get the date information and then the day, month, year function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   date = '23Jan2021'd;
   time = "12:45:18"t;
   dt   = "14Jun2021:09:23:14"dt;
   format date date9. time time8. dt datetime18.;
   dayofmonth = day(date);
   monthnumber= month(date);
   yearnumber = year(date);
   hour = hour(time);
   minutes = minute(time);
   seconds = second(time);
   dtday = day(datepart(dt));
   dtmon = month(datepart(dt));
   dthour = hour(dt);
run;
&lt;/PRE&gt;
&lt;P&gt;You want to test, as in create a variable with the value of any concatenation involving the || operator. The results may surprise you. Consider this example of concatenating a string with a numeric value 4 different ways. See the different results.&lt;/P&gt;
&lt;PRE&gt;data example2;
   length x $ 30;
   x='abcdefg';
   y=25;
   cat1 = x||y;
   cat2 = cats(x,y);
   cat3 = cat(x,y);
   cat4 = catt(x,y);
run;&lt;/PRE&gt;
&lt;P&gt;Also note in the log that only one of these provides a warning about conversion of numeric to character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The MDY function may be something to investigate to create new date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 15:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776520#M246986</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-26T15:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to change date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776530#M246990</link>
      <description>&lt;P&gt;This format will result in your wanted displayed value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;as POLICY_VINTAGE format yymmd7.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Oct 2021 15:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-date-format/m-p/776530#M246990</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-26T15:44:40Z</dc:date>
    </item>
  </channel>
</rss>

