<?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: Formatting Null Dates in Proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127029#M34819</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use a datastep and execute different code depending on the type of your column. The VTYPE function would tell you which type ("C" or "N") your imported field is. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Mar 2013 01:13:42 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-03-05T01:13:42Z</dc:date>
    <item>
      <title>Formatting Null Dates in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127028#M34818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to import various Excel files into SAS.&amp;nbsp; These files have a Date field that sometimes contains a value, but other times they are all null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After I import the data, I select all the fields using proc sql.&amp;nbsp; I can format the dates when they exist, but if they're null, then I get an error saying "Character expression requires a character format."&amp;nbsp; Here is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;EffectiveDate format yymmddn8.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like the only way to do it is to convert it to a char first, then back to a date.&amp;nbsp; Is there a better way to do this?&amp;nbsp; This is what I'm doing now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;INPUT(CATS(EffectiveDate),yymmddn8.) as EffectiveDate yymmddn8.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 20:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127028#M34818</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-04T20:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Null Dates in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127029#M34819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use a datastep and execute different code depending on the type of your column. The VTYPE function would tell you which type ("C" or "N") your imported field is. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 01:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127029#M34819</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-03-05T01:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Null Dates in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127030#M34820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suggest that when you import your data, explicitly define you date columns as numeric.&lt;/P&gt;&lt;P&gt;Depending on your import method, this done differently. Please refer to the documentation for your import method.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 10:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127030#M34820</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-03-05T10:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Null Dates in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127031#M34821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I bet Excel is guessing wrong for the variable when SAS imports it (this is assuming you are using import wizard, proc import, or libname access). As &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt; said the best / most reliable way to tackle this is to explicitly read the excel files using a data step (tab delimited should work). That way you can read the values in directly to the form you need them and format them as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is a little confusing to me is that according to the error you are getting the variable is already a character value, but maybe its in part of the code not provided.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 13:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-Null-Dates-in-Proc-SQL/m-p/127031#M34821</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-03-05T13:13:56Z</dc:date>
    </item>
  </channel>
</rss>

