<?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: how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604826#M8284</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Internally, it appears that your date values are really just DATE values stored as numeric variables. It does not appear that they are actually DATETIME variables. Assuming this to be the case, then you could just use either simple arithmetic to determine duration or you could use the fancier interval functions. Let's start with a simple example. I already have THIS data:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fakedata.png" style="width: 306px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34038iC4E6E72880B5DB0E/image-size/large?v=v2&amp;amp;px=999" role="button" title="fakedata.png" alt="fakedata.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But, even though we can all read those dates, they are stored internally as the number of days since Jan 1, 1960, which is how SAS dates are stored internally. In the data set in storage, the dates look like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="internal_values.png" style="width: 263px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34039i20C93E7FA3C93900/image-size/large?v=v2&amp;amp;px=999" role="button" title="internal_values.png" alt="internal_values.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, with a SAS-defined format, I can control the appearance of those dates, as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="use_diff_format.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34040i7F2064C9F589BB63/image-size/large?v=v2&amp;amp;px=999" role="button" title="use_diff_format.png" alt="use_diff_format.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So assuming that you just want to alter how the numeric date values appear, that can be accomplished with a FORMAT statement. We teach the FORMAT statement in our free Programming 1 e-learning class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If you want to find the number of days or number of years between the hired date and the promoted date, then because the dates are stored internally as numbers, you can do simple arithmetic. (or, there are fancier functions, but let's keep it simple for now.)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="how_long_in_job.png" style="width: 594px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34041i0AA50BDC64DCB7C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="how_long_in_job.png" alt="how_long_in_job.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the entire program, it includes the data for the WORK.FAKEDATA file that was used initially. You should be able to run everything.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fakedata;
  length name $10 jobtitle $15;
  infile datalines dlm=',';
  input name $ hired : date9. promoted : date9. jobtitle $;
return;
datalines;
Alan,15Jan1990,23Feb1995,Accountant
Barbara,15Nov2000,01Jan2003,Biophysicist
Chester,03Mar1999,21Jun2004,Chef
Diana,29Sep2014,19May2016,Deputy
Edward,01Jan2015,29Jul2018,Economist
;
run;

proc print data=fakedata;
  title '1) Use formats to control display';
  var name hired promoted jobtitle;
  format hired mmddyy10. promoted date9.;
run;

proc print data=fakedata;
  title '2) Use DIFFERENT formats to control display';
  var name hired promoted jobtitle;
  format hired monyy5. promoted mmddyy10.;
run;

proc print data=fakedata;
  title '3) Use DATE9. format to control display';
  var name hired promoted jobtitle;
  format hired promoted date9.;
run;

proc print data=fakedata;
  title '4) Show internal numbers for values';
  var name hired promoted jobtitle;
  format hired promoted;
run;

title;


data howlong;
  set fakedata;
  howlong_in_days = promoted - hired;
  howlong_in_years = howlong_in_days / 365.25;
run;

proc print data=howlong;
  title 'How Long in Original Job';
  var name hired promoted jobtitle 
      howlong_in_days howlong_in_years;
  format hired mmddyy10. promoted monyy5.;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Here's a good blog post on interval processing using SAS Functions: &lt;A href="https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Hopes this helps explain how to use the FORMAT statement and how to simply calculate duration, IF your date variables are stored as numeric variables that represent the number of days since Jan 1, 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
    <pubDate>Sun, 17 Nov 2019 18:17:04 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2019-11-17T18:17:04Z</dc:date>
    <item>
      <title>how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604815#M8281</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still a novice with SAS programming and I just downloaded the free edition of SAS Studio 3 days ago so please bear with me.. i would really appreciate some specific help with these questions cause i've been searching for hours for solutions on google&amp;nbsp; and just got more confused.Thank you in advance for any assistance provided.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st how can i convert the variable hold_month values to month-year only (i.e no day)? As you can see below in the variable attributes, I tried reformatting the date9. format from the&amp;nbsp;hold_placed_datetime variable to&amp;nbsp;the&amp;nbsp; format date7. to no avail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2nd how can I calculate the # of days between the hold_placed_datetime and hold_filled_datetime?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a copy of the dataset and proc contents I currently have:&lt;/P&gt;&lt;DIV class="dijitContentPane dijitBorderContainer-child dijitBorderContainer-dijitContentPane dijitBorderContainerPane dijitAlignTop"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="dijitContentPane dijitBorderContainer-child dijitBorderContainer-dijitContentPane dijitBorderContainerPane dijitAlignTop"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="dijitContentPane dijitBorderContainer-child dijitBorderContainer-dijitContentPane dijitBorderContainerPane dijitAlignCenter dijitContentPaneSingleChild"&gt;&lt;DIV class="dgrid dgrid-grid ui-widget"&gt;&lt;DIV class="dgrid-scroller"&gt;&lt;DIV class="dgrid-content ui-widget-content"&gt;&lt;DIV class=" dgrid-row dgrid-row-odd ui-state-default"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=" dgrid-row dgrid-row-even ui-state-default"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;hold_placed_datetime&lt;/TD&gt;&lt;TD&gt;hold_filled_datetime&lt;/TD&gt;&lt;TD&gt;source_location_code&lt;/TD&gt;&lt;TD&gt;pickup_location_code&lt;/TD&gt;&lt;TD&gt;hold_month&lt;/TD&gt;&lt;TD&gt;days_till_pickup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;28-Oct-14&lt;/TD&gt;&lt;TD&gt;18-Oct-18&lt;/TD&gt;&lt;TD&gt;Main Library&lt;/TD&gt;&lt;TD&gt;Main Library&lt;/TD&gt;&lt;TD&gt;28-Oct-14&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3-Mar-15&lt;/TD&gt;&lt;TD&gt;2-Feb-19&lt;/TD&gt;&lt;TD&gt;Forest Park Branch&lt;/TD&gt;&lt;TD&gt;Forest Park Branch&lt;/TD&gt;&lt;TD&gt;3-Mar-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2-Jun-15&lt;/TD&gt;&lt;TD&gt;20-Dec-18&lt;/TD&gt;&lt;TD&gt;Harrison Branch&lt;/TD&gt;&lt;TD&gt;Covedale Branch&lt;/TD&gt;&lt;TD&gt;2-Jun-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3-Jun-15&lt;/TD&gt;&lt;TD&gt;18-Oct-18&lt;/TD&gt;&lt;TD&gt;West End Branch&lt;/TD&gt;&lt;TD&gt;Delhi Township Branch&lt;/TD&gt;&lt;TD&gt;3-Jun-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;30-Jun-15&lt;/TD&gt;&lt;TD&gt;13-Dec-18&lt;/TD&gt;&lt;TD&gt;Hyde Park Branch&lt;/TD&gt;&lt;TD&gt;Hyde Park Branch&lt;/TD&gt;&lt;TD&gt;30-Jun-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3-Jul-15&lt;/TD&gt;&lt;TD&gt;26-Dec-18&lt;/TD&gt;&lt;TD&gt;Bond Hill Branch&lt;/TD&gt;&lt;TD&gt;Pleasant Ridge Branch&lt;/TD&gt;&lt;TD&gt;3-Jul-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3-Aug-15&lt;/TD&gt;&lt;TD&gt;18-Oct-18&lt;/TD&gt;&lt;TD&gt;Miami Township Branch&lt;/TD&gt;&lt;TD&gt;Delhi Township Branch&lt;/TD&gt;&lt;TD&gt;3-Aug-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10-Sep-15&lt;/TD&gt;&lt;TD&gt;20-Feb-19&lt;/TD&gt;&lt;TD&gt;Green Township Branch&lt;/TD&gt;&lt;TD&gt;Green Township Branch&lt;/TD&gt;&lt;TD&gt;10-Sep-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10-Sep-15&lt;/TD&gt;&lt;TD&gt;7-Jan-19&lt;/TD&gt;&lt;TD&gt;Harrison Branch&lt;/TD&gt;&lt;TD&gt;Harrison Branch&lt;/TD&gt;&lt;TD&gt;10-Sep-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9-Oct-15&lt;/TD&gt;&lt;TD&gt;12-Jul-19&lt;/TD&gt;&lt;TD&gt;Wyoming Branch&lt;/TD&gt;&lt;TD&gt;Wyoming Branch&lt;/TD&gt;&lt;TD&gt;9-Oct-15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="proc_title_group"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="proc_title_group"&gt;&lt;P class="c proctitle"&gt;The CONTENTS Procedure&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;Data Set NameObservationsMember TypeVariablesEngineIndexesCreatedObservation LengthLast ModifiedDeleted ObservationsProtectionCompressedData Set TypeSortedLabel&amp;nbsp;Data Representation&amp;nbsp;Encoding&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;WORK.IMPORT1&lt;/TD&gt;&lt;TD&gt;2518839&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DATA&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;V9&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/17/2019 11:28:03&lt;/TD&gt;&lt;TD&gt;72&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/17/2019 11:28:03&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;NO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;NO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;utf-8 Unicode (UTF-8)&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;Engine/Host Dependent InformationData Set Page SizeNumber of Data Set PagesFirst Data PageMax Obs per PageObs in First Data PageNumber of Data Set RepairsFilenameRelease CreatedHost CreatedInode NumberAccess PermissionOwner NameFile SizeFile Size (bytes)&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;65536&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2775&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;908&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;871&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;/tmp/SAS_work689500000A1F_localhost.localdomain/SAS_workF77400000A1F_localhost.localdomain/import1.sas7bdat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9.0401M6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Linux&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;541858&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;rw-rw-r--&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sasdemo&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;174MB&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;181927936&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;Alphabetic List of Variables and Attributes# Variable Type Len Format Informat625143&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;days_till_pickup&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;$1.&lt;/TD&gt;&lt;TD&gt;$1.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;hold_filled_datetime&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;DATE9.&lt;/TD&gt;&lt;TD&gt;DATE9.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;hold_month&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;DATE7.&lt;/TD&gt;&lt;TD&gt;DATE7.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;hold_placed_datetime&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;DATE9.&lt;/TD&gt;&lt;TD&gt;DATE9.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pickup_location_code&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;$21.&lt;/TD&gt;&lt;TD&gt;$21.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;source_location_code&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;$21.&lt;/TD&gt;&lt;TD&gt;$21.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sun, 17 Nov 2019 17:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604815#M8281</guid>
      <dc:creator>AYoung60</dc:creator>
      <dc:date>2019-11-17T17:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604816#M8282</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/300010"&gt;@AYoung60&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since dates are internally stored as the number of days after 01jan1960,&amp;nbsp; you can calculate the number of days between hold_filled_datetime and hold_placed_datetime as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N_of_days = hold_filled_datetime-hold_placed_datetime;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to the display of hold_month, you could&amp;nbsp;drop&amp;nbsp;display of the day-of-month component by assigning the format&amp;nbsp;&amp;nbsp; MONYY7.&amp;nbsp;&amp;nbsp; But remember the internal value is unchanged, so you could also subtract&amp;nbsp;hold_month minus some other date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 17:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604816#M8282</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-17T17:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604822#M8283</link>
      <description>&lt;P&gt;The difference between using 7 characters instead of 9 when displaying dates with the DATE format is just that there is only room for two digits of the year.&amp;nbsp; So 2019 and 1919 will be be displayed as 19.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many other formats that work for date values that you can choose from.&amp;nbsp; Look at the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n0p2fmevfgj470n17h4k9f27qjag.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n0p2fmevfgj470n17h4k9f27qjag.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;So you might want to consider these: MMYY, MONYY, YYMM, YYMON&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that change the format just changes how the value is displayed, it does not change the actual value.&amp;nbsp;If you want to convert a date to the first day of a month you can use the INTNX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hold_month=intnx('month',hold_filled_date,0,'b');
format hold_month yymm7.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that DATETIME values are stored as number of seconds and DATE values are number of days. It does not make sense to name variable as HOLD_FILLED_DATETIME and attach the DATE format to it.&amp;nbsp; Either the name is right and the value is in seconds, in which case trying to display it as if it was a date will result in a date way in the future,&amp;nbsp; or the format is right in which case the variable name will confuse users of the dataset.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 18:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604822#M8283</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-17T18:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604826#M8284</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Internally, it appears that your date values are really just DATE values stored as numeric variables. It does not appear that they are actually DATETIME variables. Assuming this to be the case, then you could just use either simple arithmetic to determine duration or you could use the fancier interval functions. Let's start with a simple example. I already have THIS data:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fakedata.png" style="width: 306px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34038iC4E6E72880B5DB0E/image-size/large?v=v2&amp;amp;px=999" role="button" title="fakedata.png" alt="fakedata.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But, even though we can all read those dates, they are stored internally as the number of days since Jan 1, 1960, which is how SAS dates are stored internally. In the data set in storage, the dates look like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="internal_values.png" style="width: 263px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34039i20C93E7FA3C93900/image-size/large?v=v2&amp;amp;px=999" role="button" title="internal_values.png" alt="internal_values.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, with a SAS-defined format, I can control the appearance of those dates, as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="use_diff_format.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34040i7F2064C9F589BB63/image-size/large?v=v2&amp;amp;px=999" role="button" title="use_diff_format.png" alt="use_diff_format.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So assuming that you just want to alter how the numeric date values appear, that can be accomplished with a FORMAT statement. We teach the FORMAT statement in our free Programming 1 e-learning class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If you want to find the number of days or number of years between the hired date and the promoted date, then because the dates are stored internally as numbers, you can do simple arithmetic. (or, there are fancier functions, but let's keep it simple for now.)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="how_long_in_job.png" style="width: 594px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34041i0AA50BDC64DCB7C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="how_long_in_job.png" alt="how_long_in_job.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the entire program, it includes the data for the WORK.FAKEDATA file that was used initially. You should be able to run everything.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fakedata;
  length name $10 jobtitle $15;
  infile datalines dlm=',';
  input name $ hired : date9. promoted : date9. jobtitle $;
return;
datalines;
Alan,15Jan1990,23Feb1995,Accountant
Barbara,15Nov2000,01Jan2003,Biophysicist
Chester,03Mar1999,21Jun2004,Chef
Diana,29Sep2014,19May2016,Deputy
Edward,01Jan2015,29Jul2018,Economist
;
run;

proc print data=fakedata;
  title '1) Use formats to control display';
  var name hired promoted jobtitle;
  format hired mmddyy10. promoted date9.;
run;

proc print data=fakedata;
  title '2) Use DIFFERENT formats to control display';
  var name hired promoted jobtitle;
  format hired monyy5. promoted mmddyy10.;
run;

proc print data=fakedata;
  title '3) Use DATE9. format to control display';
  var name hired promoted jobtitle;
  format hired promoted date9.;
run;

proc print data=fakedata;
  title '4) Show internal numbers for values';
  var name hired promoted jobtitle;
  format hired promoted;
run;

title;


data howlong;
  set fakedata;
  howlong_in_days = promoted - hired;
  howlong_in_years = howlong_in_days / 365.25;
run;

proc print data=howlong;
  title 'How Long in Original Job';
  var name hired promoted jobtitle 
      howlong_in_days howlong_in_years;
  format hired mmddyy10. promoted monyy5.;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Here's a good blog post on interval processing using SAS Functions: &lt;A href="https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Hopes this helps explain how to use the FORMAT statement and how to simply calculate duration, IF your date variables are stored as numeric variables that represent the number of days since Jan 1, 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 18:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/604826#M8284</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-11-17T18:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/605927#M8325</link>
      <description>Thank you for your help Tom. Appreciate it!&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Nov 2019 20:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/605927#M8325</guid>
      <dc:creator>AYoung60</dc:creator>
      <dc:date>2019-11-20T20:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: how do I convert dd-mmm-yy format to mmm-yy and calculate the # of days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/605930#M8326</link>
      <description>Ok. Thank you!&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Nov 2019 20:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-do-I-convert-dd-mmm-yy-format-to-mmm-yy-and-calculate-the-of/m-p/605930#M8326</guid>
      <dc:creator>AYoung60</dc:creator>
      <dc:date>2019-11-20T20:23:19Z</dc:date>
    </item>
  </channel>
</rss>

