<?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: Date in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766263#M37458</link>
    <description>&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;Advice: don't create your own text strings or numbers to represent dates. If you do that, and then at some point need to know what 6 months before 202004 is, you then have to program your own calculations as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are absolutely right !!&lt;/P&gt;
&lt;P&gt;I was too quick with my answer (and its variable 'c'), sorry.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Mon, 06 Sep 2021 20:16:24 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2021-09-06T20:16:24Z</dc:date>
    <item>
      <title>Date</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766253#M37454</link>
      <description>&lt;P&gt;I have the variable "date" whose format is in "&lt;STRONG&gt;03APR2020:00:00:00.000&lt;/STRONG&gt;", but I want to make a new variable "dt" using only "&lt;STRONG&gt;202004&lt;/STRONG&gt;". What code can I use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code below is wrong:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; tabl1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; tabl;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;dt = year(date) + month(date);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 19:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766253#M37454</guid>
      <dc:creator>Thalitacosta</dc:creator>
      <dc:date>2021-09-06T19:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Date</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766258#M37455</link>
      <description>&lt;P&gt;Try something like this.&lt;/P&gt;
&lt;P&gt;Use concatenation operator (|| or !!) and not the plus-sign.&lt;/P&gt;
&lt;P&gt;Or use CATx functions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 a='03APR2020:00:00:00.000'dt;
 put a= dtmonyy7.;
 b=datepart(a);
 put b= monyy7.;
 put b= yymmdd5.; 
 c=year(b)||'-'||put(month(b),z2.);
 put c=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 19:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766258#M37455</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-06T19:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766259#M37456</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dt = datepart(date);
format dt yymmn6.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since your "date" variable contains in fact a datetime value.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 19:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766259#M37456</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-06T19:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Date</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766262#M37457</link>
      <description>&lt;P&gt;Advice: don't create your own text strings or numbers to represent dates. If you do that, and then at some point need to know what 6 months before 202004 is, you then have to program your own calculations as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use SAS date values, these will always be more useful then your own text strings. Example from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; shows how. Then, calculations are built into SAS via the INTCK and INTNX function, so you don't have to program these calculations yourself.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 20:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766262#M37457</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-06T20:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766263#M37458</link>
      <description>&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;Advice: don't create your own text strings or numbers to represent dates. If you do that, and then at some point need to know what 6 months before 202004 is, you then have to program your own calculations as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are absolutely right !!&lt;/P&gt;
&lt;P&gt;I was too quick with my answer (and its variable 'c'), sorry.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 20:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Date/m-p/766263#M37458</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-06T20:16:24Z</dc:date>
    </item>
  </channel>
</rss>

