<?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: Replace character missing value (.) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504604#M135071</link>
    <description>&lt;P&gt;You mean by converting the displayed format like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set test1;
   if missing(KNDEIND) then KNDEIND=put(input(podverd,yymmdd10.)-1,ddmmyy10.);
   else KNDEIND=put(input(KNDEIND,yymmdd10.),ddmmyy10.);
   podverd=put(input(podverd,yymmdd10.),ddmmyy10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Oct 2018 06:57:20 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2018-10-16T06:57:20Z</dc:date>
    <item>
      <title>Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504600#M135067</link>
      <description>&lt;P&gt;Appreciate if someone of you guide me to replace the character missing value '.' with date value. I tried the following program but it is not producing the desired output. I knew dot (.) is not a valid null value for character variable, but the real data in my project is like that only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
length KNDEIND podverd $10.;
input KNDEIND $ podverd $;
datalines;
2017-11-25   2017-12-27
   .         2016-09-23     
run;


data want;
set test1;
if missing(KNDEIND) then KNDEIND=put(input(podverd,yymmdd10.)-1,yymmddd10.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Desired output:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="150"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="75"&gt;KNDEIND&lt;/TD&gt;
&lt;TD width="75"&gt;podverd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;25/11/2017&lt;/TD&gt;
&lt;TD&gt;27/12/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;SPAN&gt;22/09/2016&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;23/09/2016&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 16 Oct 2018 06:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504600#M135067</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-16T06:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504603#M135070</link>
      <description>&lt;P&gt;Storing dates as character is as stupid as it gets, because it deprives you of using all the nice features SAS provides with regards to dates and times.&lt;/P&gt;
&lt;P&gt;Then the whole thing is done in one very simple step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
input (kndeind podverd) (:yymmdd10.);
format kndeind podverd yymmddd10.;
if kndeind = . then kndeind = podverd - 1;
datalines;
2017-11-25   2017-12-27
   .         2016-09-23     
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Oct 2018 06:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504603#M135070</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T06:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504604#M135071</link>
      <description>&lt;P&gt;You mean by converting the displayed format like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set test1;
   if missing(KNDEIND) then KNDEIND=put(input(podverd,yymmdd10.)-1,ddmmyy10.);
   else KNDEIND=put(input(KNDEIND,yymmdd10.),ddmmyy10.);
   podverd=put(input(podverd,yymmdd10.),ddmmyy10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Oct 2018 06:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504604#M135071</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-10-16T06:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504606#M135072</link>
      <description>&lt;P&gt;It is not, especially if you expect partial Dates &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504606#M135072</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-10-16T07:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504607#M135073</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If you know that a dot in the character variable represents a missing then just test for a string with a dot in it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  length KNDEIND podverd $10.;
  input KNDEIND $ podverd $;
  datalines;
2017-11-25   2017-12-27
   .         2016-09-23     
;
run;

data want;
  set test1;
  if KNDEIND in (' ','.') then
    KNDEIND=put(input(podverd,yymmdd10.)-1,yymmddd10.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504607#M135073</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-16T07:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504608#M135074</link>
      <description>Assume the values in those two variables are in character. Then how will&lt;BR /&gt;you achieve the desired result?&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504608#M135074</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-16T07:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504609#M135075</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It is not, especially if you expect partial Dates &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I said &lt;EM&gt;storing&lt;/EM&gt;, not &lt;EM&gt;reading.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;In the case of incomplete data, I read into a temporary character variable, and create complete data in the first step. Crappy data needs to be fixed/cleaned at the first point of entry into the data warehouse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504609#M135075</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T07:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504612#M135077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Assume the values in those two variables are in character. Then how will&lt;BR /&gt;you achieve the desired result?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I go to the dumb-ass who created that mess and apply a &lt;A href="http://www.catb.org/jargon/html/L/LART.html" target="_blank"&gt;LART&lt;/A&gt;. Just kidding.&lt;/P&gt;
&lt;P&gt;On second thought, no kidding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the data, I'd permanently convert it to a SAS date and be done with it. Most probably by fixing the defective code that's responsible for the character "dates" in the first place&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504612#M135077</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T07:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504614#M135078</link>
      <description>&lt;P&gt;I ran your code and it is not producing the desired output:(&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504614#M135078</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-16T07:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504615#M135079</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I ran your code and it is not producing the desired output:(&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can't be.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  length KNDEIND podverd $10.;
  input KNDEIND $ podverd $;
  datalines;
2017-11-25   2017-12-27
   .         2016-09-23     
;
run;

data want;
  set test1;
  if KNDEIND in (' ','.') then
    KNDEIND=put(input(podverd,yymmdd10.)-1,yymmddd10.);
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(Exactly the code from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;, witha proc print added)&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt; KNDEIND       podverd

2017-11-25    2017-12-27
2016-09-22    2016-09-23
&lt;/PRE&gt;
&lt;P&gt;Exactly matches your initial requirement.&lt;/P&gt;
&lt;P&gt;If you want different formats, use them.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504615#M135079</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T07:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504627#M135083</link>
      <description>&lt;P&gt;I'm not certain why I'm unable to achieve this in DI studio. None of the missing values are converted into date value as defined in the code below. Under expression, I gave the code as follows. Am I missing something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when KNDEIND in (' ','.')  then put(input(PODVERD,yymmdd10.)-1,yymmddd10.) 
else KNDEIND 
end&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My data is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="114"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="114"&gt;KNDEIND&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;01/01/2011&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504627#M135083</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-16T08:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504636#M135087</link>
      <description>&lt;P&gt;So your "dates" changed from year-month-day to (maybe) day-month-year? You need to change the informat used to match your data!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504636#M135087</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-10-16T08:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504642#M135092</link>
      <description>&lt;P&gt;Is your data really character?&amp;nbsp; Its just that having a dot there really looks like missing numeric.&amp;nbsp; In which case you don't need to be converting.&lt;/P&gt;
&lt;P&gt;Also your logic is the wrong way round:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;case when KNDEIND &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'.'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't want to convert if its missing!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post some accurate test data in a working datastep, which reflects the data your are actually using, don't just type something in and assume.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504642#M135092</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-16T08:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504644#M135093</link>
      <description>&lt;P&gt;You have a value in DMY or MDY order, but use a YMD format/informat.&lt;/P&gt;
&lt;P&gt;Please post the log of that whole step.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 09:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504644#M135093</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T09:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504966#M135208</link>
      <description>I am talking about storing. Especially in pharma one Encounters all the time partial Dates, this is every day practice and most of the time can not be cleaned.</description>
      <pubDate>Wed, 17 Oct 2018 05:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504966#M135208</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-10-17T05:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Replace character missing value (.)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504978#M135211</link>
      <description>&lt;P&gt;But in pharma, you would be using the standard CDISC models, so SDTM would be ISO dates - can have partials, ADaM would have ISO and converted numeric date, time, datetime where possible to convert.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 07:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-character-missing-value/m-p/504978#M135211</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-17T07:11:27Z</dc:date>
    </item>
  </channel>
</rss>

