<?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: Default date values to end of month in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582486#M13848</link>
    <description>&lt;P&gt;Thank you Novinosrin, this also seems like it would work, will give it a shot too!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2019 16:22:46 GMT</pubDate>
    <dc:creator>PSU_Sudzi</dc:creator>
    <dc:date>2019-08-20T16:22:46Z</dc:date>
    <item>
      <title>Default date values to end of month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582480#M13844</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a piece of code that I use (below) to default missing days from partial dates to the first of the month when appropriate but in this case I need to default the missing days to the end of the month, which seems more complicated to a novice like me since the last day of the month can vary. Any ideas how to proceed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* month and year entered, default to start of month */&lt;/P&gt;&lt;P&gt;if substr(eoslvdat,1,1) = '-' and substr(eoslvdat,3,1) ne '-' then eoslvdtn=input(trim('01')||substr(eoslvdat,3),date9.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.EOS;
  infile datalines dsd truncover;
  input _usubjid:$6. eoslvdat:$9.;
  label _usubjid="Unique Subject Identifier" eoslvdat="Date of last visit";
datalines;
01/001 25APR2019
01/002 02MAY2019
01/003 08OCT2018
01/004 15NOV2018
01/005 12JUN2018
01/006 06JUN2019
01/007 --DEC2018
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 16:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582480#M13844</guid>
      <dc:creator>PSU_Sudzi</dc:creator>
      <dc:date>2019-08-20T16:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Default date values to end of month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582483#M13845</link>
      <description>Convert them to SAS dates and then use INTNX to set to the end of the month.&lt;BR /&gt;&lt;BR /&gt;1. Use TRANSLATE to convert the -- to 01&lt;BR /&gt;I'll leave that to you. Do you have more than missing days you need to account for? You can use the code you already have to put it as 01.&lt;BR /&gt;2. Convert to SAS date using INPUT()&lt;BR /&gt;new_var = input(eoslvdat, date9.);&lt;BR /&gt;3. Change to end of the month&lt;BR /&gt;new_var = intnx('month', new_var, 0, 'e');</description>
      <pubDate>Tue, 20 Aug 2019 16:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582483#M13845</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-20T16:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Default date values to end of month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582484#M13846</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data WORK.EOS;
  infile datalines  dlm=' ' truncover;
  input _usubjid:$6. eoslvdat :$9.;
  label _usubjid="Unique Subject Identifier" eoslvdat="Date of last visit";
datalines;
01/001 25APR2019
01/002 02MAY2019
01/003 08OCT2018
01/004 15NOV2018
01/005 12JUN2018
01/006 06JUN2019
01/007   DEC2018
;;;;

data want;
set eos;
want=input(eoslvdat,?? date9.);
if want=. then want=intnx('mon',input(cats('01',eoslvdat),date9.),0,'e');
format want date9.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And suppose you have full missing values for your eoslvdat variable, the above is modified to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set eos;
if not missing(eoslvdat) then do;
want=input(eoslvdat,?? date9.);
if want=. then want=intnx('mon',input(cats('01',eoslvdat),date9.),0,'e');
end;
format want date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 16:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582484#M13846</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-20T16:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Default date values to end of month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582485#M13847</link>
      <description>&lt;P&gt;Thanks for the response Reeza. In this dataset I only need to account for missing days, not months or years as I might in others. I hadn't thought of converting the -- to 01 and then using INTNX, but that seems like a good idea!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 16:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582485#M13847</guid>
      <dc:creator>PSU_Sudzi</dc:creator>
      <dc:date>2019-08-20T16:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Default date values to end of month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582486#M13848</link>
      <description>&lt;P&gt;Thank you Novinosrin, this also seems like it would work, will give it a shot too!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 16:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Default-date-values-to-end-of-month/m-p/582486#M13848</guid>
      <dc:creator>PSU_Sudzi</dc:creator>
      <dc:date>2019-08-20T16:22:46Z</dc:date>
    </item>
  </channel>
</rss>

