<?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: How to make SAS recognize a user-defined format as a date? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810649#M319682</link>
    <description>&lt;P&gt;At least for Redshift it just says "&lt;SPAN&gt;DATE formats".&amp;nbsp; I&lt;/SPAN&gt;t does not really list which formats it recognizes as "DATE formats".&lt;/P&gt;
&lt;P&gt;I think the issue the OP was having is that is not seeing the user defined format as a "DATE format".&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1651240651377.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70984i354470B2907DEB20/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1651240651377.png" alt="Tom_0-1651240651377.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 13:59:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-29T13:59:09Z</dc:date>
    <item>
      <title>How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810571#M319639</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have defined the following format-informat pair:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc format;
	invalue irtdate "N/A" = .a
		other = [date11.];
	value irtdate .a = "       N/A" 
		other = [e8601da10.];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, SAS does not recognize these as date formats. This causes the data to be uploaded to an SQL DB as float instead of datetime2. Is there a solution to this issue? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 10:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810571#M319639</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2022-04-29T10:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810583#M319644</link>
      <description>&lt;P&gt;Look into data set option &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p1dqaq7ub1cm1pn1ow3x9qkmkxe8.htm" target="_self"&gt;dbtype&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;I've made - at least with earlier versions and some databases - the experience that SAS even doesn't always get it right with OOTB date and datetime formats. I therefore always try to apply formats date9. and datetime20. before uploading any SAS table to a database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now with your format: Not sure what conversion you would expect to happen for&amp;nbsp;&lt;EM&gt;.a = " N/A"&lt;/EM&gt;&amp;nbsp; even if using &lt;EM&gt;dbtype&lt;/EM&gt;. Special missings are a SAS "thing" so not sure how SAS could convert this to a value for a DB. Also: You wouldn't expect to get "N/A" on the DB side, would you? What gets transferred to the database are the unformatted internal values.&lt;/P&gt;
&lt;P&gt;IF you want to store the formatted values in the database then you would need to load a string - and it would become a CHAR or VARCHAR on the DB side. IF you want to load a string then use your format on the SAS side to populate a character variable and then load this character variable to the database.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 11:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810583#M319644</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-04-29T11:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810601#M319656</link>
      <description>&lt;P&gt;Regarding the intention: I am OK if the data are uploaded as NULL, I merely wanted to avoid having a ton of invalid data messages during the file import. I guess I can adjust the format to map N/A to . and then use standard date format for the dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810601#M319656</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2022-04-29T12:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810605#M319659</link>
      <description>&lt;P&gt;What code are you using to upload?&lt;/P&gt;
&lt;P&gt;Can't you just include a FORMAT statement to attach DATE format to the variables for the upload step?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810605#M319659</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T12:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810610#M319663</link>
      <description>&lt;P&gt;I use&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
 create table odbc.foo as select * from saslib.foo;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have now dropped my custom formats and adapted the informats to map N/A to . instead of .a. The values were uploaded as datetime2 so it looks like it worked.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810610#M319663</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2022-04-29T12:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810612#M319665</link>
      <description>&lt;P&gt;Did you try defining it as a picture format instead?&amp;nbsp; Does it recognize it a date value then?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture irtdate 
   .a = '       N/A' 
   .  = '         .'
  other = '%Y-%0m-%0d' (datatype=date)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810612#M319665</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T12:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810613#M319666</link>
      <description>&lt;P&gt;I tried something similar, it did not work either.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810613#M319666</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2022-04-29T12:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810614#M319667</link>
      <description>&lt;P&gt;So that is different than inserting into an existing table.&lt;/P&gt;
&lt;P&gt;Using the DBTYPE= dataset option is probably recommended if you really want control over how the variables are defined in the remote database.&amp;nbsp; But it will require more code.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810614#M319667</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T12:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810642#M319678</link>
      <description>&lt;P&gt;You don't give enough information to fully understand the problem, but I can see from the format you gave that it may cause a faulty data conversion to the SQL DB.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using SAS/ACCESS to &amp;lt;name your relational database&amp;gt; to interface with the DB, SAS makes an educated guess what data type to create on the DB-side based on the SAS data type and format. Since SAS only has 2 data types (numeric and character), it also uses the format to give additional clues for granularity. If you look at the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p1lp99cyhab6e3n1wp6ohbpz0z5e.htm" target="_blank" rel="noopener"&gt;documentation for SAS/ACCESS&lt;/A&gt;, it will tell you the formats it recognizes to properly create the SQL DB data type and perform the conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You didn't specify which SQL DB you are working with, but I checked a couple of the ones I use mostly (Teradata and MS SQL Server) and the&amp;nbsp;e8601da10. format is not listed as one of the formats for creating date data type on DB-side. You may want to try date. or datetime. Better yet click the link I provided and check out your specific DB.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 13:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810642#M319678</guid>
      <dc:creator>average_joe</dc:creator>
      <dc:date>2022-04-29T13:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810649#M319682</link>
      <description>&lt;P&gt;At least for Redshift it just says "&lt;SPAN&gt;DATE formats".&amp;nbsp; I&lt;/SPAN&gt;t does not really list which formats it recognizes as "DATE formats".&lt;/P&gt;
&lt;P&gt;I think the issue the OP was having is that is not seeing the user defined format as a "DATE format".&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1651240651377.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70984i354470B2907DEB20/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1651240651377.png" alt="Tom_0-1651240651377.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 13:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810649#M319682</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T13:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810660#M319689</link>
      <description>&lt;P&gt;As I mentioned, he doesn't give enough information to pinpoint the issue. You think it may be that the format is not applied to the SAS data, and, therefore, doesn't get properly created on the DB-side. I suggest that the format is properly applied but not recognized by the SAS/ACCESS engine to properly create it on the DB-side. My suggestion is based on Teradata stating that any other numeric format that is not listed results in a float.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE id="n1glmq9y38d6vxn14e0bucxz5lg7" class="xisDoc-table"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-horizontalLeft xisDoc-verticalTop xisDoc-forScope" scope="row"&gt;
&lt;P class="xisDoc-paragraph"&gt;Numeric&lt;/P&gt;
&lt;/TH&gt;
&lt;TD class="xisDoc-horizontalLeft xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;all other numeric formats&lt;/P&gt;
&lt;/TD&gt;
&lt;TD class="xisDoc-horizontalLeft xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;FLOAT&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 14:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810660#M319689</guid>
      <dc:creator>average_joe</dc:creator>
      <dc:date>2022-04-29T14:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810994#M319860</link>
      <description>&lt;P&gt;I am using SAS/ACCESS to ODBC and loading data to MS SQL Server. As with Teradata, date formats should in theory be recognised as SQL_DATE. This works for e8601da. without issues, it is just my user-defined format with the additional missing values causing problems.&lt;/P&gt;&lt;P&gt;As mentioned earlier, the idea behind using it was to avoid excessive log spam due to N/A values. But, as I do not need the values after the import, I have adapted my informat as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc format;
	invalue irtdate "N/A" = .
		other = [date11.];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and formatted the values as e8601da afterwards. This has allowed me to both avoid the errors in the log and to load the data into the DB as a proper data type.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 06:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/810994#M319860</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2022-05-02T06:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to make SAS recognize a user-defined format as a date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/811027#M319876</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223838"&gt;@js5&lt;/a&gt;&amp;nbsp;Because SAS doesn't have a data type of Date, Datetime, Time, Timestamp or similar the only way SAS can identify that a variable of type NUM (double) requires conversion to a Date/Time specific DB data type is via a format attached to the variable or via the DBTYPE option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's a SAS Format then it needs to be part of some internal list of OOTB formats as nothing within a custom format identifies it as a specific date, datetime or time format - so SAS simply can't "know" that a mapping to anything else than a DB type Double is required.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 10:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-SAS-recognize-a-user-defined-format-as-a-date/m-p/811027#M319876</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-05-02T10:07:31Z</dc:date>
    </item>
  </channel>
</rss>

