<?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: format date into SAS format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851070#M336347</link>
    <description>&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI&gt;this is not my code&lt;/LI&gt;
&lt;LI&gt;whenever you have errors or other messages you can't make sense of, post the complete log of the step into a window opened with this button:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Sun, 25 Dec 2022 14:03:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-12-25T14:03:34Z</dc:date>
    <item>
      <title>format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851059#M336341</link>
      <description>&lt;P&gt;Hi SAS expert, I have a date in the format of yyyymm, how to format in SAS date ?&lt;/P&gt;&lt;P&gt;yyyymm&lt;/P&gt;&lt;P&gt;196507&lt;/P&gt;&lt;P&gt;196508&lt;/P&gt;&lt;P&gt;196509&lt;/P&gt;&lt;P&gt;196510&lt;/P&gt;&lt;P&gt;196511&lt;/P&gt;&lt;P&gt;196512&lt;/P&gt;&lt;P&gt;196601&lt;/P&gt;&lt;P&gt;196602&lt;/P&gt;&lt;P&gt;196603&lt;/P&gt;&lt;P&gt;196604&lt;/P&gt;&lt;P&gt;196605&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2022 10:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851059#M336341</guid>
      <dc:creator>Nieves</dc:creator>
      <dc:date>2022-12-25T10:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851061#M336342</link>
      <description>&lt;P&gt;The informat instructs SAS how to read a text string for conversion to a SAS Date value, the format instructs SAS how to print the SAS Date value.&lt;/P&gt;
&lt;P&gt;The SAS Date value created will be the first of the month. You can use another format like DATE9. to also print the date.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  attrib my_dt length=8 informat=yymmn6. format=yymmn6.;
  input my_dt;
  datalines;
196507
196508
196509
196510
196511
196512
196601
196602
196603
196604
196605
;

proc print data=sample;
run;

proc print data=sample;
  format my_dt date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1671964110925.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78868i640F4898693DA684/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1671964110925.png" alt="Patrick_0-1671964110925.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2022 10:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851061#M336342</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-12-25T10:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851062#M336343</link>
      <description>Thank you very much. By the way, if I would like to generate two date variables, first day of one month after the yyyymm and last day of one month after the yyyymm, how shall I implement this ?&lt;BR /&gt;&lt;BR /&gt;yyyymm date1 date2&lt;BR /&gt;196507 19650801 19650831&lt;BR /&gt;196508 19650901 19650930&lt;BR /&gt;196509 19651001 19761031&lt;BR /&gt;</description>
      <pubDate>Sun, 25 Dec 2022 12:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851062#M336343</guid>
      <dc:creator>Nieves</dc:creator>
      <dc:date>2022-12-25T12:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851066#M336345</link>
      <description>&lt;P&gt;Use the INTNX function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date1 = intnx('month',yyyymm,1,'b');
date2 = intnx('month',yyyymm,1,'e');
format date1 date2 yymmddn8.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Dec 2022 13:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851066#M336345</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-25T13:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851068#M336346</link>
      <description>Thanks. If I modify the code as follows, there seems an error. May I seek your advice ?&lt;BR /&gt;data syy.data2;&lt;BR /&gt;set syy.data1;&lt;BR /&gt;attrib yyyymm length=8 informat=yymmn6. format=yymmn6.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data syy.data3;&lt;BR /&gt;set syy.data2;&lt;BR /&gt;format yyyymm date9.;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Sun, 25 Dec 2022 13:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851068#M336346</guid>
      <dc:creator>Nieves</dc:creator>
      <dc:date>2022-12-25T13:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851070#M336347</link>
      <description>&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI&gt;this is not my code&lt;/LI&gt;
&lt;LI&gt;whenever you have errors or other messages you can't make sense of, post the complete log of the step into a window opened with this button:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 25 Dec 2022 14:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851070#M336347</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-25T14:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851071#M336348</link>
      <description>Thanks. If I modify the code as follows, there seems an error. May I seek your advice ?&lt;BR /&gt;data syy.data2;&lt;BR /&gt;set syy.data1;&lt;BR /&gt;attrib yyyymm length=8 informat=yymmn6. format=yymmn6.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data syy.data3;&lt;BR /&gt;set syy.data2;&lt;BR /&gt;format yyyymm date9.;&lt;BR /&gt;run;</description>
      <pubDate>Sun, 25 Dec 2022 14:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851071#M336348</guid>
      <dc:creator>Nieves</dc:creator>
      <dc:date>2022-12-25T14:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: format date into SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851072#M336349</link>
      <description>&lt;P&gt;Attaching a format to an existing variable does not change the values stored in the variable.&lt;/P&gt;
&lt;P&gt;So if you have a numeric variable that has a value like 196,507 and tell SAS to use the YYMMN6. format to display it then it will treat that number as the number of days since 1960 so that number would mean&amp;nbsp;&amp;nbsp;06JAN2498.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to convert the number 196,507 to the date 01JUL1965 then you need to convert it.&amp;nbsp; Since INFORMATs convert text to numbers you first need to use a FORMAT to convert the number to a text string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data syy.data2;
  set syy.data1;
  yyyymm = input(put(yyyymm,z6.),yymmn6.);
  format yyyymm date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Dec 2022 15:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format-date-into-SAS-format/m-p/851072#M336349</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-25T15:06:56Z</dc:date>
    </item>
  </channel>
</rss>

