<?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: Odd issues with date variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234389#M42861</link>
    <description>&lt;P&gt;Can you post a couple of lines of test data which reflects the data you have. &amp;nbsp;This seems to run fine, so I assume your data is at fault somewhere:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data temp;
  reldate="01jan2104"d; dob="10oct2010"d; months=.; output;
  reldate="12jan2104"d; dob="10oct2010"d; months=2; output;
run;
data example; 
  set temp;
	added_days=0;
	if months&amp;gt;0 then added_days=months*30;

	*Change the release date to account for the additional days;
	new_rel=intnx('days',reldate,added_days);
	format new_rel mmddyy8.;

	*Calculate age at release using YRDIF;
	if dob ne . and new_rel ne . then relage=round(yrdif(dob,new_rel,"AGE"));

	*Add a variable to conditionally exclude non-2005 releases;
	exclude=0;
	if year(new_rel) ne 2005 then exclude=1;
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Nov 2015 15:10:57 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-11-12T15:10:57Z</dc:date>
    <item>
      <title>Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234385#M42860</link>
      <description>&lt;P&gt;I'm getting an odd error when running certain functions on date variables in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example; set base.dataset;
	added_days=0;
	if months&amp;gt;0 then added_days=months*30;

	*Change the release date to account for the additional days;
	new_rel=intnx('days',reldate,added_days);
	format new_rel mmddyy8.;

	*Calculate age at release using YRDIF;
	if dob ne . and new_rel ne . then relage=round(yrdif(dob,new_rel,"AGE"));

	*Add a variable to conditionally exclude non-2005 releases;
	exclude=0;
	if year(new_rel) ne 2005 then exclude=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;At the intnx() and year() lines, SAS is throwing up a Missing Value warning for about 20% of my observations. I've checked the data, and reldate, new_rel, and added_days have no missing values that I can find. The warning doesn't show on the yrdif() line, presumably because of the "new_rel ne ." condition. The data seems fine when I run procedures on it afterwards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions for what's going on here?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 14:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234385#M42860</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2015-11-12T14:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234389#M42861</link>
      <description>&lt;P&gt;Can you post a couple of lines of test data which reflects the data you have. &amp;nbsp;This seems to run fine, so I assume your data is at fault somewhere:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data temp;
  reldate="01jan2104"d; dob="10oct2010"d; months=.; output;
  reldate="12jan2104"d; dob="10oct2010"d; months=2; output;
run;
data example; 
  set temp;
	added_days=0;
	if months&amp;gt;0 then added_days=months*30;

	*Change the release date to account for the additional days;
	new_rel=intnx('days',reldate,added_days);
	format new_rel mmddyy8.;

	*Calculate age at release using YRDIF;
	if dob ne . and new_rel ne . then relage=round(yrdif(dob,new_rel,"AGE"));

	*Add a variable to conditionally exclude non-2005 releases;
	exclude=0;
	if year(new_rel) ne 2005 then exclude=1;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 15:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234389#M42861</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-12T15:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234393#M42862</link>
      <description>&lt;P&gt;If the data step does not stop prematurely, dataset EXAMPLE will have the same number of observations as BASE.DATASET. So, if NEW_REL has a missing value (generated by applying INTNX to a missing argument, as your description suggests)&amp;nbsp;in the n-th observation of &lt;EM&gt;EXAMPLE&lt;/EM&gt;, I would scrutinize the relevant variable values of n-th observation of &lt;EM&gt;BASE.DATASET&lt;/EM&gt;. Maybe you will find a &lt;EM&gt;special&lt;/EM&gt; missing value, which would &lt;EM&gt;not&lt;/EM&gt; satisfy a condition like "&lt;FONT face="courier new,courier"&gt;reldate eq .&lt;/FONT&gt;".&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234393#M42862</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-12T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234400#M42863</link>
      <description>&lt;P&gt;You most likely have missing data. Does the following generate any missing data in the table?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=base.dataset;
table reldate added_dates new_rel/missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 15:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234400#M42863</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-12T15:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234406#M42864</link>
      <description>&lt;PRE&gt;reldate    months       days     new_rel

16910         0           0      16910
16873         0           0      16873
16785         0           0      16785
16778         0           0      16778
16776         0           0      16776
16897         0           0      16897
17276         6           0      17276
16775         0           0      16775
16778         0           0      16778
16814         0           0      16814
16707         0           0      16707
16789         0           0      16789
16777         0           0      16777
16715         0           0      16715
16722         0           0      16722
16743         5         150      16893
16651         0           0      16651
16687         0           0      16687
16783         2          60      16843
17090         0           0      17090
16768         0           0      16768
16777         0           0      16777
16939         0           0      16939
16611         0           0      16611
16499         0           0      16499
16950         0           0      16950
16791         0           0      16791
16776         0           0      16776
16763         0           0      16763
17122         0           0      17122
16814         0           0      16814
16785         0           0      16785
16716         0           0      16716
&lt;/PRE&gt;
&lt;P&gt;The majority of the observations have a value of 0 for months, so added_days is generally 0. The number of observations that are throwing the Missing Value warning (5,541) is much larger than the number of observations with a value other than 0 for added_days (1,563). All of the values for added_days are a multiple of 30, ranging from 30 to 540.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234406#M42864</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2015-11-12T16:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234407#M42865</link>
      <description>&lt;P&gt;Nope. All observations show as having a non-missing value for those variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Which is to say that neither reldate nor months show as missing in the base dataset. added_days and new_rel don't exist there; they're created in the data step I posted as part of the question (and they don't show any missing values, either).&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234407#M42865</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2015-11-12T16:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234409#M42866</link>
      <description>&lt;P&gt;I'm not getting specific information as to which observations are causing problems. All I see in the log is:&lt;/P&gt;
&lt;PRE&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      5541 at 834:13   5541 at 852:8
&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234409#M42866</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2015-11-12T16:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234413#M42867</link>
      <description>&lt;P&gt;INTNX should have a parameter of DAY not DAY&lt;U&gt;&lt;STRONG&gt;S&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also explicitly output the errors when they occur using PUT statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example; set base.dataset;
	added_days=0;
	if months&amp;gt;0 then added_days=months*30;

	*Change the release date to account for the additional days;
	new_rel=intnx('day',reldate,added_days);
	format new_rel mmddyy8.;

        if new_rel = . then do;
            put 'Reldate:'  reldate;
            put 'Added_Days:' added_days;
         end;

	*Calculate age at release using YRDIF;
	if dob ne . and new_rel ne . then relage=round(yrdif(dob,new_rel,"AGE"));

	*Add a variable to conditionally exclude non-2005 releases;
	exclude=0;
	if year(new_rel) ne 2005 then exclude=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234413#M42867</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-12T16:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234421#M42870</link>
      <description>SAS doesn't seem to care either way about day vs days, but the PUT is showing that the problem observations are missing on reldate. Which is weird, because there aren't any missing values for that variable on either the input or output dataset.</description>
      <pubDate>Thu, 12 Nov 2015 17:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234421#M42870</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2015-11-12T17:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234431#M42871</link>
      <description>From the log msg shown here identify the lines in the code where the problem occurs.&lt;BR /&gt;insert there&lt;BR /&gt;If {var name becoming missing} =. Then do;&lt;BR /&gt;Mycount+1; if mycount&amp;lt;5 then put _all_; end;&lt;BR /&gt;That should dump all vars to the log and you might see what is going wrong at that point</description>
      <pubDate>Thu, 12 Nov 2015 18:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234431#M42871</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2015-11-12T18:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234432#M42872</link>
      <description>&lt;P&gt;Earlier you wrote that "&lt;SPAN&gt;All I see in the log is" the note "Missing values were generated ...". However, if INTNX is applied to a missing second (or third) argument, that note should be preceded by a note of the following form:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Argument 2 to function INTNX('days',.,1) at line 323 column 10 is invalid.
reldate=. months=0 dob=-2356 added_days=1 new_rel=. relage=. exclude=1 _ERROR_=1 _N_=1234
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;In this example you would see that observation no. 1234 must contain the missing value. What do the corresponding two lines in your log look like? Actually there should be more than just two, given your 5541 "missing value" notes.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 18:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234432#M42872</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-12T18:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Odd issues with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234435#M42873</link>
      <description>Please post the output from the following, and the log.&lt;BR /&gt;&lt;BR /&gt;proc meansdata=base.dataset  N NMISS;&lt;BR /&gt;var reldate;&lt;BR /&gt;output out=check n=N nmiss=Missing;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Nov 2015 18:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-issues-with-date-variables/m-p/234435#M42873</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-12T18:26:59Z</dc:date>
    </item>
  </channel>
</rss>

