<?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: Dataset contains a character value in a date column and I can't manipulate it in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411883#M279738</link>
    <description>&lt;P&gt;It's probably the setting of your missing= option. Try this for reference:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options missing=C;
data test;
format mydate yymmddn8.;
mydate = today();
output;
mydate = .;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and then change the value of the option.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2017 11:59:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-11-09T11:59:25Z</dc:date>
    <item>
      <title>Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411741#M279728</link>
      <description>&lt;P&gt;I have a dataset that contains a start date and an end date. The end date column occasionally contains a "C" character, which supposedly stands for "current." I simply need to manipulate this value and change it to a date far in the future or even today's date. The format of the column is YYMMDDN8 Numeric. See screenshot below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-11-08 15_38_17-SAS.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16532iBF299A6CF7718630/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-11-08 15_38_17-SAS.png" alt="2017-11-08 15_38_17-SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am quite familiar with SQL, although outside of the context of SAS, and this seems to be a pretty simple solution using SQL code. I have tried the following statement shown in the log below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-11-08 15_39_19-SAS.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16533iB059140377D6B987/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-11-08 15_39_19-SAS.png" alt="2017-11-08 15_39_19-SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, as you can see from the error above, SAS does not want to compare the numeric type of the column with the 'C' character value, even though this column clearly contains that value. I have attempted changing the format of the column with PUT(), but I was still not able to get a case statement to work as formatted above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Environment: SAS 9.4 for Windows&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411741#M279728</guid>
      <dc:creator>noahmyers</dc:creator>
      <dc:date>2017-11-08T22:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411742#M279729</link>
      <description>&lt;P&gt;Strip the formats and print a small sample to see what the underlying value is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=dataname (obs=100);
var dateEndRole;
format dateEndRole;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411742#M279729</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T22:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411745#M279730</link>
      <description>&lt;P&gt;Running the following code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=PERM.CEOtenure;
var dateEndRole;
format dateEndRole;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Returned&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-11-08 15_56_11-SAS.png" style="width: 166px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16534i7073AE22B8853E78/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-11-08 15_56_11-SAS.png" alt="2017-11-08 15_56_11-SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411745#M279730</guid>
      <dc:creator>noahmyers</dc:creator>
      <dc:date>2017-11-08T22:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411748#M279731</link>
      <description>&lt;P&gt;The only other thing I can think of, is that they're missing, with a missing show as C for some reason?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the missing function as your filter?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where missing(dateEndRole);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411748#M279731</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T23:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411755#M279732</link>
      <description>&lt;P&gt;It looks like you are correct. Running this code successfully returns only 'C' values.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=PERM.CEOtenure;
var dateEndRole;
format dateEndRole;
where missing(dateEndRole);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So in SQL, does this count as a NULL value?&amp;nbsp;I still can't manipulate the data as I am used to. Where am I going wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table PERM.CEOTENURE5 as
		SELECT * 
			  ,CASE DateEndRole
			  		WHEN NULL THEN today()
					ELSE DateEndRole
			   END as DateEndRoleF
		FROM PERM.CEOTENURE
		;
	quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-11-08 16_05_43-SAS.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16537iB8ECF196778ABD9E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-11-08 16_05_43-SAS.png" alt="2017-11-08 16_05_43-SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411755#M279732</guid>
      <dc:creator>noahmyers</dc:creator>
      <dc:date>2017-11-08T23:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411756#M279733</link>
      <description>&lt;P&gt;It appears possible that your data has been read in such a way the actual value is a special missing. If your raw data when read contains .C&amp;nbsp; (please notice the . before the C) this could be the cause.&lt;/P&gt;
&lt;P&gt;If that is the actual case you should be able to use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if dateendrole= .C then dateendrole = today();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see this brief example of a similar data.&lt;/P&gt;
&lt;PRE&gt;data junk;
   input x;
datalines;
1
3
.C
4
;
run;

Proc print data=junk;
run;

data newjunk;
   set junk;
   if x=.C then x=-99;
run;
proc print data=newjunk;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411756#M279733</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-08T23:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411758#M279734</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The only other thing I can think of, is that they're missing, with a missing show as C for some reason?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the missing function as your filter?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where missing(dateEndRole);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps the missing option is set;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options missing='C';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or more likely it is special missing value .C&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Probably to indicate continuing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411758#M279734</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-11-08T23:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411759#M279735</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table PERM.CEOTENURE5 as
		SELECT * 
			  ,CASE 
			  		WHEN missing(dateEndRole) THEN today()
					ELSE DateEndRole
			   END as DateEndRoleF
		FROM PERM.CEOTENURE
		;
	quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411759#M279735</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T23:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411770#M279736</link>
      <description>&lt;P&gt;The value is the special missing .C. You can test for .C or using the MISSING() function to find those values. You can replace them using IF/THEN logic or just use the COALESCE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data perm.ceotenure2 ;
  set perm.ceotenure;
  dateendrolef = coalesce(dateendrole,today());
  format dateendrolef yymmdd10. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you create a new variable the make sure to attach a date format to it so that it prints in human readable form.&amp;nbsp; If you want to print in YMD format then YYMMDD10. is more legible or humans than YYMMDD8. since without the hyphens it looks like a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411770#M279736</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-08T23:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411785#M279737</link>
      <description>&lt;P&gt;I ended up using coalesce in the original data pull and everything worked beautifully.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;coalesce(A.DateEndRole, today()) as DateEndRole format=yymmddn8.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you Rezza and Tom for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 00:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411785#M279737</guid>
      <dc:creator>noahmyers</dc:creator>
      <dc:date>2017-11-09T00:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset contains a character value in a date column and I can't manipulate it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411883#M279738</link>
      <description>&lt;P&gt;It's probably the setting of your missing= option. Try this for reference:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options missing=C;
data test;
format mydate yymmddn8.;
mydate = today();
output;
mydate = .;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and then change the value of the option.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 11:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-contains-a-character-value-in-a-date-column-and-I-can-t/m-p/411883#M279738</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-09T11:59:25Z</dc:date>
    </item>
  </channel>
</rss>

