<?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: Problem when formatting a date variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109962#M30544</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The format to use would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mmddyyn8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is some question as to whether that would apply as is, or whether you need to change your data as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enrl_drop_dt = datepart(enrl_drop_dt);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It all depends on what your variable contains.&amp;nbsp; If it's a date variable, leave it as is.&amp;nbsp; If it's a date-time variable, you'll have to apply DATEPART.&amp;nbsp; So try it with just the format and see how the dates look.&amp;nbsp; If they are far too large, apply DATEPART.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Aug 2013 21:17:55 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-08-13T21:17:55Z</dc:date>
    <item>
      <title>Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109957#M30539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to format a date variable that currently has a date16 format.&lt;/P&gt;&lt;P&gt;There are . for missing values for the variable. I need to reformat this but I get an ERROR: There was a problem with the format so BEST. was used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure what is going on. or how to work around.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 20:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109957#M30539</guid>
      <dc:creator>Martinez77</dc:creator>
      <dc:date>2013-08-13T20:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109958#M30540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does date16. look like? In my version of SAS date9. is the biggest format I can have. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Post what your dates currently look like and what you want them to look like, eg. reformat to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 20:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109958#M30540</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-08-13T20:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109959#M30541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;29MAR2013:00:00:00&lt;/P&gt;&lt;P&gt;This is what they currently look like.&lt;/P&gt;&lt;P&gt;I want it to appear like this: 03292013&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks you for your help,&lt;/P&gt;&lt;P&gt;Martinez77&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 20:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109959#M30541</guid>
      <dc:creator>Martinez77</dc:creator>
      <dc:date>2013-08-13T20:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109960#M30542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this to reformat "mydate":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mydate=datepart(mydate);&lt;BR /&gt;put mydate mmddyyn8.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 21:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109960#M30542</guid>
      <dc:creator>CTorres</dc:creator>
      <dc:date>2013-08-13T21:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109961#M30543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should have been a little more clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable in my data set name enrl_drop_dt which contains date values as below:&lt;/P&gt;&lt;P&gt;29MAR2013:00:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are missing values with a . if missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need them to display as shown below:&lt;/P&gt;&lt;P&gt;03292013&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping I could do it in a data step&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data bla;&lt;/P&gt;&lt;P&gt;set bla;&lt;/P&gt;&lt;P&gt;format enrl_drop_dt mmddyyy6.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that shines some light&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Martinez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 21:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109961#M30543</guid>
      <dc:creator>Martinez77</dc:creator>
      <dc:date>2013-08-13T21:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109962#M30544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The format to use would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mmddyyn8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is some question as to whether that would apply as is, or whether you need to change your data as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enrl_drop_dt = datepart(enrl_drop_dt);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It all depends on what your variable contains.&amp;nbsp; If it's a date variable, leave it as is.&amp;nbsp; If it's a date-time variable, you'll have to apply DATEPART.&amp;nbsp; So try it with just the format and see how the dates look.&amp;nbsp; If they are far too large, apply DATEPART.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 21:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109962#M30544</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-13T21:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109963#M30545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So your variable is actually a datetime variable, not a date variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use some date formats specifically on datetime variables, but the one you require isn't...AFAIK. That leaves you with two options, 1) Recode your variable to a true date variable so you can apply the date variable or 2) Create your own format that you can apply.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first option was suggested by CTorres above in a data step.&amp;nbsp; The second partly depends on what version of SAS you have, do you have SAS 9.3. In SAS 9.3 you can use functions in a format so it becomes relatively straight forward then. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 21:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109963#M30545</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-08-13T21:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when formatting a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109964#M30546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all very much. I had a typo in my format. Fixed it and the datepart function worked great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another sas win.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Martinez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 21:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-when-formatting-a-date-variable/m-p/109964#M30546</guid>
      <dc:creator>Martinez77</dc:creator>
      <dc:date>2013-08-13T21:26:40Z</dc:date>
    </item>
  </channel>
</rss>

