<?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/976476#M378349</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466238"&gt;@dxiao2017&lt;/a&gt;&amp;nbsp;! I did use Tom's suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am now trying to use the same part of the code to create a string variable that shows the date as 7/27/2025 9:00:00 AM&lt;/P&gt;&lt;P&gt;It is probably a simple tweak but I am unsure how to make it work. See my question to Tom above.&lt;/P&gt;&lt;P&gt;Truly appreciate the help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Oct 2025 16:49:02 GMT</pubDate>
    <dc:creator>Mscarboncopy</dc:creator>
    <dc:date>2025-10-06T16:49:02Z</dc:date>
    <item>
      <title>Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973458#M377691</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;Is there a way to apply this date format without having multiple rows of the same statement below? I will have hundreds of different dates and I need them to have this format so that I can further work with them .&lt;/DIV&gt;&lt;DIV class=""&gt;DATE ='27AUG25:09:00:00'dt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&lt;/DIV&gt;&lt;DIV class=""&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;27JUL25:09:00:00&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05AUG25:10:00:00&lt;/DIV&gt;&lt;DIV class=""&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15AUG25:08:00:00&lt;/DIV&gt;&lt;DIV class=""&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20AUG25:11:30:00&lt;/DIV&gt;&lt;DIV class=""&gt;...&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Thanks!&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Aug 2025 20:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973458#M377691</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2025-08-27T20:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973462#M377692</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; I'm not sure what you want. Remember that a SAS date value is stored internally as a number and a SAS date/time value is also stored internally as a number. The format that you show is only how the variable is displayed in output, such as reports. Without any format being applied, you can prove this to yourself by running this program:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1756330885492.jpeg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109349i3C610B61B61FDE19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1756330885492.jpeg" alt="Cynthia_sas_1-1756330885492.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; That very large number that is stored internally represents the number of seconds between midnight on Jan 1 1960 and your date/time value. If you already have date/time variables stored in your data, then your assignment statement is NOT applying a format. If you want to apply a format to change the way your variable is displayed, you would use a FORMAT statement or&amp;nbsp; for the PUTLOG statement, you can specify the format after the variable to be displayed in the log. Note the difference between a format with a width of 20 and the format with a width of 18 -- that will give you the 2 digit year you seem to want. Just remember that your assignment statement is NOT storing your date/time value in a readable format --your numeric date/time value is ALWAYS stored as a number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Perhaps if you could explain a bit more about your data and what you need to do, it would be easier to understand why you think the assignment statement is necessary.&lt;/P&gt;&lt;P&gt;Cynthia&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2025 21:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973462#M377692</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2025-08-27T21:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973466#M377693</link>
      <description>&lt;P&gt;There are two ways to produce that type of a listing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your variable named DATE has DATETIME values with the DATETIME format attached to it with a width between 16 and 18.&amp;nbsp; NOTE: the DATETIME format has a bug and you must specify at width of at least 19 for it to actually print the 18 characters needed to display datetime value with 4 digit years.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id date :datetime.;
  format date datetime16.;
cards;
1 27JUL25:09:00:00 
2 05AUG25:10:00:00
3 15AUG25:08:00:00
4 20AUG25:11:30:00
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But then I do not know what you are asking for help with since you already have the value as a datetime.&amp;nbsp;&lt;STRONG&gt; If the variable is datetime already what is your actual question?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But perhaps instead you have the DATE variable defined as CHARACTER instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id date :$16.;
cards;
1 27JUL25:09:00:00 
2 05AUG25:10:00:00
3 15AUG25:08:00:00
4 20AUG25:11:30:00
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both of those will print the same way:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1756336519004.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109350i2D34DD1E7A334631/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1756336519004.png" alt="Tom_0-1756336519004.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case to work with those values as actual datetime values you will need to first convert them.&amp;nbsp; And you will need to make a new variable since the variable DATE is already defined as a character variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  datetime = input(date,datetime24.);
  format datetime datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1756336554025.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109351i45B3FBDB8F8E2457/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1756336554025.png" alt="Tom_1-1756336554025.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note it does not matter if you have 4 observations or hundreds or millions the code is the same.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2025 23:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973466#M377693</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-27T23:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973471#M377695</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;Sorry,&amp;nbsp; I should have added what I want to do with it.&lt;/P&gt;&lt;P&gt;I want to break the date var into several other vars (See outcome below).&lt;/P&gt;&lt;P&gt;It looks like I need the Date var to be formatted the way I asked in my previous message for this next part of my code to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;proc format;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; value dayofweek&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 1 = 'Sunday'&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 2 = 'Monday'&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 3 = 'Tuesday'&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 4 = 'Wednesday'&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 5 = 'Thursday'&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 6 = 'Friday'&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; &amp;nbsp; 7 = 'Saturday';&lt;/DIV&gt;&lt;DIV class=""&gt;run;&lt;/DIV&gt;&lt;DIV class=""&gt;data final;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; set test;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; dated = datepart(Date);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; time = timepart(Date);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; day_of_week = weekday(dated);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; month = month(dated);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; day = day(dated);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; year = year(dated);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; hour = hour(time);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; minute = minute(time);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp; second = second(time);&lt;/DIV&gt;&lt;DIV class=""&gt;format date date9.;&lt;/DIV&gt;&lt;DIV class=""&gt;format time timeampm.;&lt;/DIV&gt;&lt;DIV class=""&gt;format day_of_week dayofweek.;&lt;/DIV&gt;&lt;DIV class=""&gt;run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Result of this (showing only one obs)&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;dated&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; day_of_week month day year&amp;nbsp; &amp;nbsp;hour minute &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;DIV&gt;27AUG2025&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;9:00:00 AM&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;Wednesday&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;8&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;27&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;2025&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;9&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;0&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea here is to use these variables elsewhere to show the following:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Wednesday, August 27, 2025 9:00 AM&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Aside from figuring out how to apply that format to hundreds of dates,&amp;nbsp;&lt;SPAN class=""&gt;I still need to:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;1. label the Month to display the string not the numeric value 8 like I did for day_of_week. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2. remove the extra 00 in my time variable.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;3. I do not need the hour and the minute vars but I created them just in case.&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I do not know another way to achieve this output unless I format my Date var the way I showed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;My date variable is the long SAS number which I am converting to a date format (the one you see in my cards)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Aug 2025 01:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973471#M377695</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2025-08-28T01:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973472#M377696</link>
      <description>&lt;P&gt;Why do you need to make so many new variables?&lt;/P&gt;
&lt;P&gt;Why not just apply different formats for different levels of granularity?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get very close to that desired output using a PICTURE format.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id date :datetime.;
  format date datetime16.;
cards;
1 27JUL25:09:00:00
2 05AUG25:10:00:00
3 15AUG25:08:00:00
4 20AUG25:21:30:00
;

/*
Wednesday, August 27, 2025 9:00 AM  
*/
proc format ;
 picture mydt (default=40)
 low-high= '%F, %C %d, %Y %H:%0M %p' (datatype=datetime);
;
run;

proc print data=have;
 format date mydt.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    id                     date

 1      1     Sunday   , July      27, 2025 9:00 AM
 2      2     Tuesday  , August    5, 2025 10:00 AM
 3      3     Friday   , August    15, 2025 8:00 AM
 4      4    Wednesday, August    20, 2025 21:30 PM&lt;/PRE&gt;
&lt;P&gt;You might want to run it though the COMPBL() function however.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  string = left(compbl(put(date,mydt.)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    id                date                  string

 1      1    27JUL25:09:00:00    Sunday , July 27, 2025 9:00 AM
 2      2    05AUG25:10:00:00    Tuesday , August 5, 2025 10:00 AM
 3      3    15AUG25:08:00:00    Friday , August 15, 2025 8:00 AM
 4      4    20AUG25:21:30:00    Wednesday, August 20, 2025 21:30 PM&lt;/PRE&gt;
&lt;P&gt;Might need to add a TRANWRD() function call also.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  string = tranwrd(left(compbl(put(date,mydt.))),' ,',',');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Aug 2025 01:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973472#M377696</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-28T01:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973474#M377698</link>
      <description>&lt;P&gt;Perhaps this is what you are trying to do?&lt;/P&gt;
&lt;P&gt;First let's name you variable that has DATETIME values as DATETIME instead of DATE to avoid confusion in our example.&amp;nbsp; And display it with 4 digit years for the same reason.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id datetime :datetime.;
  format datetime datetime19.;
cards;
1 27JUL25:09:00:00
2 05AUG25:10:00:00
3 15AUG25:08:00:00
4 20AUG25:21:30:00
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now we can make that complex string using the CATX() and PUT functions.&amp;nbsp; It does make the code simpler to first make a variable with just the DATE (number of days since 1960).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length string $50;
  date=datepart(datetime);
  format date date9.;
  string = catx(', '
           ,put(date,downame.)
           ,catx(' ',put(date,monname.),day(date))
           ,put(datetime,timeampm.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    id               datetime                 string                      date

 1      1     27JUL2025:09:00:00    Sunday, July 27, 9:00:00 AM         27JUL2025
 2      2     05AUG2025:10:00:00    Tuesday, August 5, 10:00:00 AM      05AUG2025
 3      3     15AUG2025:08:00:00    Friday, August 15, 8:00:00 AM       15AUG2025
 4      4     20AUG2025:21:30:00    Wednesday, August 20, 9:30:00 PM    20AUG2025
&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Aug 2025 01:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973474#M377698</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-28T01:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973475#M377699</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;There is a problem in your output, was it right ?&lt;/P&gt;
&lt;PRE&gt; 1      1    27JUL25:09:00:00    Sunday , July 27, 2025 9:00 AM
 2      2    05AUG25:10:00:00    Tuesday , August 5, 2025 10:00 AM
 3      3    15AUG25:08:00:00    Friday , August 15, 2025 8:00 AM
 4      4    20AUG25:&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;21:30:00&lt;/STRONG&gt; &lt;/FONT&gt;   Wednesday, August 20, 2025 &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;21:30 PM&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Anyway , there is another way to get this format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc fcmp outlib=work.math.func;
function fmt(datetime) $;
length fmt $ 60;
fmt=catx(' ',put(datepart(datetime),weekdate32.),put(timepart(datetime),timeampm8.));
return (fmt);
endsub;
run;
options cmplib=work.math;
proc format;
value fmt(default=60)
other=[fmt()]
;
run;

data have;
  input id date :datetime.;
  format date fmt.;
cards;
1 27JUL25:09:00:00
2 05AUG25:10:00:00
3 15AUG25:08:00:00
4 20AUG25:21:30:00
;

proc print data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Aug 2025 02:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973475#M377699</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-28T02:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973505#M377702</link>
      <description>Moved to new thread</description>
      <pubDate>Thu, 28 Aug 2025 11:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/973505#M377702</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-28T11:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/974040#M377789</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210474"&gt;@Mscarboncopy&lt;/a&gt;&amp;nbsp;, maybe you already figured out the answer base on others' reply, but here is my version of code (mainly base on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s reply), and I think these are effective and efficient solution according to your request.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dtfmt1;
   input ID DATE datetime16.;
   datedt16=date;
   format datedt16 datetime16.;
   datalines;
1 27JUL25:09:00:00 
2 05AUG25:10:00:00
3 15AUG25:08:00:00
4 20AUG25:11:30:00
;
run;
proc print data=dtfmt;run;
data dtfmt2(drop=date datedt16);
   set dtfmt1;
   dated=datepart(date);
   time=timepart(date);
   day_of_week=weekday(dated);
   month=month(dated);
   day=day(dated);
   year=year(dated);
   format dated date9.
          time timeampm8.
          day_of_week downame.
          month monname.;
run;
proc print data=dtfmt2;run;
proc format;
   picture mydt(default=40)
           low-high='%F,%c %d,%Y %H:%0M %p'
           (datatype=datetime);
run;
data dtfmt3;
   set dtfmt1;
   format date mydt.;
   datechar=put(date,mydt.);
run;
proc print data=dtfmt3;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1756910371059.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109582i217CA5F57A46BB1D/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1756910371059.png" alt="dxiao2017_0-1756910371059.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210474"&gt;@Mscarboncopy&lt;/a&gt;&amp;nbsp;, several techniques perhaps you would like to know: 1)if one wants to display a month's number in character month name,&lt;EM&gt; monname.&lt;/EM&gt; format works, similarly,&amp;nbsp;&lt;EM&gt;weekday()&lt;/EM&gt; function returns a number, if one want to display the character weekday, &lt;EM&gt;downame.&lt;/EM&gt; format works (and you do not need to use &lt;EM&gt;proc format 1='Monday'&lt;/EM&gt; etc.), and I just learnt it from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s reply, 2) use &lt;EM&gt;timeampm8.&lt;/EM&gt; format to reduce the &lt;EM&gt;00:00:00&lt;/EM&gt; time format to &lt;EM&gt;00:00&lt;/EM&gt;, 3)if one would like to display date/time in a specific format, use picture format (and I copied this from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s reply), and if one would like to further convert it to character string,&amp;nbsp;&lt;EM&gt;put(date/time, picfmt.)&lt;/EM&gt; is the efficient way, and &lt;EM&gt;catx()&lt;/EM&gt; is not a good way to do it because nested functions such as &lt;EM&gt;catx(catx())&lt;/EM&gt; is a bit too complicated and cost a lot of eyesight.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 14:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/974040#M377789</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-09-03T14:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976472#M378348</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Sorry it took me so long to get back to this. I used your suggestion and it worked. Thank you!!!&lt;/P&gt;&lt;P&gt;Now I am trying to find out how to use the same variable and create a date like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;7/27/2025 9:00:00 AM&lt;/P&gt;&lt;P&gt;I think someone mentioned I could do this but using this part of the code what would I change to get 7/27/2025 9:00:00 AM using my first observation as an example: Thank you!!&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;length string $50;
  date=datepart(datetime);
  format date date9.;
  string = catx(', '
           ,put(date,downame.)
           ,catx(' ',put(date,monname.),day(date))
           ,put(datetime,timeampm.));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 15:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976472#M378348</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2025-10-06T15:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976476#M378349</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466238"&gt;@dxiao2017&lt;/a&gt;&amp;nbsp;! I did use Tom's suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am now trying to use the same part of the code to create a string variable that shows the date as 7/27/2025 9:00:00 AM&lt;/P&gt;&lt;P&gt;It is probably a simple tweak but I am unsure how to make it work. See my question to Tom above.&lt;/P&gt;&lt;P&gt;Truly appreciate the help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 16:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976476#M378349</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2025-10-06T16:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976482#M378352</link>
      <description>&lt;P&gt;It is not clear what you want to do as the code you posted does not match the example string you say you want to create.&amp;nbsp; Why are you adding the month name if you don't want that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also do you really want to suppress the leading zeros in month number and day number?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not then use the MMDDYY format to make the date string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data test;
2      datetime=datetime();
3      format datetime datetime19. ;
4      length string $50;
5      string = catx(' ',put(datepart(datetime),mmddyys10.),put(datetime,timeampm.));
6      put (_all_) (=/);
7    run;


datetime=06OCT2025:13:41:54
string=10/06/2025 1:41:54 PM
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you do want to suppress the leading zeros then perhaps just use use the MONTH,DAY and YEAR functions?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  datetime=datetime();
  format datetime datetime19. ;
  length string $50;
  date=datepart(datetime);
  format date date9.;
  string = catx(' ',catx('/',month(date),day(date),year(date)),put(datetime,timeampm.));
  put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really want AM and PM in lowercase you could add the LOWCASE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  string = catx(' ',catx('/',month(date),day(date),year(date)),lowcase(put(datetime,timeampm.)));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;string=10/6/2025 1:46:33 pm
&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Oct 2025 17:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976482#M378352</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-10-06T17:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976485#M378354</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; The string is exactly what I needed - first example you gave me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 18:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format/m-p/976485#M378354</guid>
      <dc:creator>Mscarboncopy</dc:creator>
      <dc:date>2025-10-06T18:59:35Z</dc:date>
    </item>
  </channel>
</rss>

