<?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: Is there a better way to address missing date value issue? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402934#M97896</link>
    <description>&lt;P&gt;I suggest that you use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Amounts;
infile datalines dsd dlm=' ' TRUNCOVER;
length Name $15;
input 
    Name $ 
    Date ?? :date.
    Amt dollar10.; 
format date yymmdd.;
datalines;
"Ankerton,L." 08OCT96 92
"Ankerton,L." 15Oct96 43
"Davis,R." 04Oct96 16
"Masters,T." 13Oct96 18
"Masters,T."   27
"Thomas,A." 21Oct96 15
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 10 Oct 2017 19:57:10 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-10-10T19:57:10Z</dc:date>
    <item>
      <title>Is there a better way to address missing date value issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402903#M97879</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;Good afternoon. I was trying to resolve the missing date issue as shown in the name "Masters T."&amp;nbsp; 27. I tried several options including dlm dsd missover, and finally the if then statement worked. However, the log still shows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Invalid data for Date in line 98 14-20.&lt;BR /&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;98 "Masters,T." 27&lt;BR /&gt;Name=Masters,T. Date=. Amt=27 _ERROR_=1 _N_=5&lt;BR /&gt;NOTE: The data set WORK.AMOUNTS has 6 observations and 3 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.10 seconds&lt;BR /&gt; cpu time 0.06 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Programmatically, what is the correct way to address the missing date value? Please advise. Thank you very much for your review and help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data clients;&lt;/P&gt;
&lt;P&gt;infile datalines dsd dlm=' ' MISSOVER;&lt;BR /&gt; length Name $15.;&lt;BR /&gt;input Name $ EmpID $;&lt;BR /&gt;datalines;&lt;BR /&gt;"Ankerton,L." 11123&lt;BR /&gt;"Davis,R." 22298&lt;BR /&gt;"Masters,T." 33351&lt;BR /&gt;"Womer,B." 44483&lt;BR /&gt;;&lt;BR /&gt;data Amounts;&lt;BR /&gt; infile datalines dsd dlm=' ' MISSOVER;&lt;BR /&gt; length Name $15.;&lt;BR /&gt; input Name $ &lt;BR /&gt; Date date7. &lt;BR /&gt; Amt dollar3.; &lt;BR /&gt;if Date=' ' then Amt='27';&lt;BR /&gt;datalines;&lt;BR /&gt;"Ankerton,L." 08OCT96 92&lt;BR /&gt;"Ankerton,L." 15Oct96 43&lt;BR /&gt;"Davis,R." 04Oct96 16&lt;BR /&gt;"Masters,T." 13Oct96 18&lt;BR /&gt;"Masters,T."&amp;nbsp; &amp;nbsp;27&lt;BR /&gt;"Thomas,A." 21Oct96 15&lt;BR /&gt;;&lt;BR /&gt;proc sort data=clients;&lt;BR /&gt;by Name;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=Amounts;&lt;BR /&gt;by Name;&lt;BR /&gt;run;&lt;BR /&gt;data clientsamtcomb;&lt;BR /&gt; merge clients Amounts;&lt;BR /&gt; BY Name;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=clientsamtcomb;&lt;BR /&gt;format date date7. Amt dollar3.;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402903#M97879</guid>
      <dc:creator>Murali11</dc:creator>
      <dc:date>2017-10-10T19:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to address missing date value issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402923#M97887</link>
      <description>&lt;P&gt;The right way to refer to missing values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if date = . then amount = 27;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On a side note, you may need to increase the format width for printing AMOUNT.&amp;nbsp; If AMOUNT if 110 (which could be read with the DOLLAR3. informat in your top DATA step), you would still need 4 characters (not 3) to print out the value as $110.&amp;nbsp; So the FORMAT statement in the final PROC PRINT should use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format amount dollar4.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get back to your original question, the right way to address the data problem is to fix the data.&amp;nbsp; Try adding an extra blank in the data in place of the missing date.&amp;nbsp; Then the combination of DSD and DLM=' ' should be able to figure out what belongs where.&amp;nbsp; No guarantees on that, but worth a try.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402923#M97887</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-10T19:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to address missing date value issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402931#M97893</link>
      <description>&lt;P&gt;When the date is missing, you see that AMT is not read in.&amp;nbsp; In your example the number 27 is read with informat DATE7. and fails, and also AMT is set to missing.&amp;nbsp; So you put in this fix:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;if date=' ' then amt=27;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;which has 2 problems&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The expression &lt;EM&gt;&lt;STRONG&gt;IF DATE=' '&lt;/STRONG&gt;&lt;/EM&gt; compares the character value " " to the numeric variable DATE.&amp;nbsp; You should use:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;IF DATE=.&lt;/EM&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;which will eliminate the "Character values have been converted to numeric values" note&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;More importantly you're assigning the value 27, which works great if DATE is missing only when the intended AMT is 27.&amp;nbsp; You need a more general correction:&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data amounts;
  infile datalines dsd dlm=' ' MISSOVER;
  length Name $15.;
  input Name $    Date date7.    Amt dollar3.  ;
  format date date9.;
  if date=. and amt=. then amt=input(scan(_infile_,-1,' '),best32.);
datalines;
"Ankerton,L." 08OCT96 92
"Ankerton,L." 15Oct96 43
"Davis,R." 04Oct96 16
"Masters,T." 13Oct96 18
"Masters,T."   27
"Thomas,A." 21Oct96 15
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that AMT is always present and is always the last space-separated term in the input line (which is referred to via the automatic variable _INFILE.&amp;nbsp; The SCAN function gets the "-1" term (i.e. the last term - first from the end).&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402931#M97893</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-10T19:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to address missing date value issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402934#M97896</link>
      <description>&lt;P&gt;I suggest that you use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Amounts;
infile datalines dsd dlm=' ' TRUNCOVER;
length Name $15;
input 
    Name $ 
    Date ?? :date.
    Amt dollar10.; 
format date yymmdd.;
datalines;
"Ankerton,L." 08OCT96 92
"Ankerton,L." 15Oct96 43
"Davis,R." 04Oct96 16
"Masters,T." 13Oct96 18
"Masters,T."   27
"Thomas,A." 21Oct96 15
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402934#M97896</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-10T19:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to address missing date value issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402944#M97901</link>
      <description>&lt;P&gt;Hi PGStats,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your solution worked really well as it removed the error that I had received when trying with the "IF ...THEN" statement. Thank you so much for your timely help. I appreciate it. The fact that the combination of DSD and MISSOVER or individually on their own should have worked and not sure why they did not work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again,&lt;BR /&gt;&lt;BR /&gt;Murali&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 20:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-better-way-to-address-missing-date-value-issue/m-p/402944#M97901</guid>
      <dc:creator>Murali11</dc:creator>
      <dc:date>2017-10-10T20:19:27Z</dc:date>
    </item>
  </channel>
</rss>

