<?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 Format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797250#M255908</link>
    <description>&lt;P&gt;If the output should be 23FEB1998 in one case and 1973 in another case, I think the best thing you can do is leave the variables as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the output should be 23FEB1998 in one case and 01JAN1973 in another case, I think then you could easily read the results into a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    dt='1988-02-23'; output;
    dt='1973'; output;
run;
data want;
    set have;
    num_dt=input(cats(dt,'-01-01'),yymmdd10.);
    format num_dt date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Feb 2022 15:41:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-02-18T15:41:46Z</dc:date>
    <item>
      <title>Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797249#M255907</link>
      <description>&lt;P&gt;I have a dataset that has the column:&lt;/P&gt;&lt;P&gt;BRTHDTC - Character&lt;/P&gt;&lt;P&gt;1988-02-23&lt;BR /&gt;1973&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to get a numerical BRTHDTC&amp;nbsp; that takes the column BRTHDT in date9. format.&lt;/P&gt;&lt;P&gt;BRTHDT&lt;/P&gt;&lt;P&gt;23FEB1998&lt;/P&gt;&lt;P&gt;1973&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips on how to get my desired date field?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kumar&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 15:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797249#M255907</guid>
      <dc:creator>Santhosh01382</dc:creator>
      <dc:date>2022-02-18T15:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797250#M255908</link>
      <description>&lt;P&gt;If the output should be 23FEB1998 in one case and 1973 in another case, I think the best thing you can do is leave the variables as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the output should be 23FEB1998 in one case and 01JAN1973 in another case, I think then you could easily read the results into a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    dt='1988-02-23'; output;
    dt='1973'; output;
run;
data want;
    set have;
    num_dt=input(cats(dt,'-01-01'),yymmdd10.);
    format num_dt date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Feb 2022 15:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797250#M255908</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-18T15:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797253#M255911</link>
      <description>&lt;P&gt;To create a SAS date value where the Date9 or any other date format will apply correctly, you need a day, month and year value. What day and month do you expect to have in the result when only a year , apparently, is supplied? Are the year only values always provided as 4 digits?&lt;/P&gt;
&lt;P&gt;Do you have any other layouts for that character date value? We may need to see more to get code that works more completely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This provides an example of how to read those two values into dates. You get to pick the month and day to use as the default for the MDY function that turns numeric month, day and year into a date. I used January 1 for the example.&lt;/P&gt;
&lt;PRE&gt;data example;
   input BRTHDTC :$15.;
   if length(BRTHDTC)=4 then brthdt = mdy(1,1, input(BRTHDTC,4.));
   else brthdt=input(BRTHDTC,yymmdd10.);
   format brthdt date9.;
datalines;
1988-02-23
1973
;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Feb 2022 15:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/797253#M255911</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-18T15:50:37Z</dc:date>
    </item>
  </channel>
</rss>

