<?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: Concat substrings for dates in SAS-Teradata in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575315#M162714</link>
    <description>This makes no sense.  If you test for value EP00 in this variable then the variable can only be a string&lt;BR /&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = 'EP00' THEN SUBSTR(FIELD_DATE, 5, 4) || '1127' ELSE SUBSTR(FIELD_DATE, 1, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; END&lt;BR /&gt;&lt;BR /&gt;Something is very unclear.&lt;BR /&gt;</description>
    <pubDate>Mon, 22 Jul 2019 09:50:37 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-07-22T09:50:37Z</dc:date>
    <item>
      <title>Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/574902#M162516</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have performed a job&amp;nbsp;to load data from a source table to a target table in Teradata with SAS Data Integration. However, I am facing an issue&amp;nbsp;with a specific transformation related to a date format. For example, I need to transform the specific date 01/04/2015 to 27/11/2015, in a way that the target table in Teradata must contain the date 27/11/2015 instead of the date 01/04/2015 after the load job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this task, I am applying the following code, but I am getting the value 04/11/2017 instead of 27/11/2015 (the rest of dates provided by the 'ELSE' clause&amp;nbsp;are correct):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
      insert into DB.TARGET_TABLE (   
         DBCREATE_TABLE_OPTS = 'primary index NONAME1 ("BUDGET") ', 
         BUDGET, FIELD_DATE
      )
      select
         SOURCE_TABLE.BUDGET length = 12   
            format = $12.
            informat = $12.
            label = 'BUDGET',
         CASE WHEN (INPUT(PUT(FIELD_DATE,8.),BEST32.)) = '01APR2015'd THEN INPUT(CATS(SUBSTR(PUT(FIELD_DATE,8.),1,4),'1127'),BEST32.) ELSE INPUT(SUBSTR(PUT(FIELD_DATE,8.),1,8),BEST32.) END FORMAT DATE9. AS FIELD_DATE length = 8   
            format = DATE9.
            informat = DATE9.
            label = 'FIELD_DATE',
      from
         DB.SOURCE_TABLE as SOURCE_TABLE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The format of the attribute&amp;nbsp;FIELD_DATE of the mentioned tables in Teradata is 'YYYYMMDD'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 10:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/574902#M162516</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-19T10:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575195#M162642</link>
      <description>&lt;P&gt;Why doesn't his work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      
CASE WHEN FIELD_DATE = '01APR2015'd 

THEN mdy(11, 27, year(FIELD_DATE)) 

ELSE FIELD_DATE END 

FORMAT DATE9. AS FIELD_DATE length = 8   
        &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Jul 2019 11:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575195#M162642</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-21T11:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575213#M162655</link>
      <description>&lt;P&gt;If the variable is a date already why are you playing games with the value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INPUT(PUT(FIELD_DATE,8.),BEST32.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;says take a number and convert into an 8 character string and then read that string as if it was a number.&amp;nbsp; (Note that there is no such thing as a "BEST" informat, SAS will just use the normal 32. informat instead.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So unless the number has decimal fraction (or is too big to be displayed in 8 digits) then it will be unchanged.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And this code is not going to generate a valid date&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INPUT(CATS(SUBSTR(PUT(FIELD_DATE,8.),1,4),'1127'),BEST32.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you are again just using the normal 32. informat to read the generated string will be read as a regular number.&amp;nbsp; So something like 20151127 will generate 20,151,127 instead of a value like '27NOV2017'd which would be the number&amp;nbsp; 21,150 since that is how many days since start of 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if FIELD_DATE did have a valid date value like '27NOV2017'd then printing it as 8 character string would yield '&amp;nbsp; &amp;nbsp;21150' and taking the first 4 characters would yield '&amp;nbsp; &amp;nbsp;2'.&amp;nbsp; So the result would be the number 21,127. Which is the date: '04NOV2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the code is just doing what you told it to do.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jul 2019 18:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575213#M162655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-21T18:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575309#M162710</link>
      <description>&lt;P&gt;Thank you for your response, I have tried with your code and my example works completely fine. The problem here is that in a realistic context I have to deal with a source table containing a FIELD_DATE with VARCHAR format (instead of a DATE format) and with values like 'EP002019', which refers to extra pays of a particular year (in this case, 2019), so I need to load into the target table something like '27/11/2019', that's why I used the SUBSTR function in my previous example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, I am applying the functions SUBSTR&amp;nbsp;and MDY but it does not change such an expression 'EP002019':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN INPUT(SUBSTR(PUT(FIELD_DATE,8.),1,4),DATE9.) = 'EP00' THEN MDY(11, 27, YEAR(FIELD_DATE)) ELSE INPUT(SUBSTR(PUT(FIELD_DATE,8.),1,8),BEST32.) END FORMAT DATE9. AS FIELD_DATE length = 8   
            format = DATE9.
            informat = DATE9.
            label = 'FIELD_DATE',&lt;/PRE&gt;&lt;P&gt;I can easily perform this transformation in Teradata by the SUBSTR function and standard SQL with the following statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = 'EP00' THEN SUBSTR(FIELD_DATE, 5, 4) || '1127' ELSE SUBSTR(FIELD_DATE, 1, 8) END&lt;/PRE&gt;&lt;P&gt;but I don't know how to implement it in SAS.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 09:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575309#M162710</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T09:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575310#M162711</link>
      <description>The teradata code you posted at the end of your reply is valid SAS code. &lt;BR /&gt;</description>
      <pubDate>Mon, 22 Jul 2019 09:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575310#M162711</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-22T09:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575313#M162712</link>
      <description>&lt;P&gt;Thank you for your explanation. I was playing with the functions INPUT and PUT to check the corresponding&amp;nbsp;conversion, because of the requirement of the SUBSTR function to work with a character argument in SAS, since I would like to use such a function to implement this transformation in SAS, if possible.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 09:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575313#M162712</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T09:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575314#M162713</link>
      <description>&lt;P&gt;With the Teradata code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = 'EP00' THEN SUBSTR(FIELD_DATE, 5, 4) || '1127' ELSE SUBSTR(FIELD_DATE, 1, 8) END&lt;/PRE&gt;&lt;P&gt;in SAS I get the error Function SUBSTR requires a character expression as argument 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, the format of FIELD_DATE in the source table is VARCHAR(8), whereas the corresponding field of the target table is associated with a DATE format.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 09:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575314#M162713</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T09:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575315#M162714</link>
      <description>This makes no sense.  If you test for value EP00 in this variable then the variable can only be a string&lt;BR /&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = 'EP00' THEN SUBSTR(FIELD_DATE, 5, 4) || '1127' ELSE SUBSTR(FIELD_DATE, 1, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; END&lt;BR /&gt;&lt;BR /&gt;Something is very unclear.&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Jul 2019 09:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575315#M162714</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-22T09:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575325#M162719</link>
      <description>&lt;P&gt;Let me simplify the problem: if I have the value '04012019' in the source table with VARCHAR format and I want to load the value '27/11/2019' in the target table with DATE format, then the previous code in SAS referring to these values still yields the error message "Function SUBSTR requires a character expression as argument 1":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = '0401'&lt;BR /&gt;THEN SUBSTR(FIELD_DATE, 5, 4) || '1127'&lt;BR /&gt;ELSE SUBSTR(FIELD_DATE, 1, 8) END&lt;/PRE&gt;&lt;P&gt;but&amp;nbsp;I can run the process without this error message by&amp;nbsp;applying the following&amp;nbsp;code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(PUT(FIELD_DATE,8.), 5, 4) = '0401'
THEN INPUT(SUBSTR(PUT(FIELD_DATE,8.), 1, 4) || '1127',BEST32.)
ELSE INPUT(SUBSTR(PUT(FIELD_DATE,8.), 1, 8),BEST32.) END length = 8&lt;/PRE&gt;&lt;P&gt;however, the value '27/11/2019' is not loaded into the target table and&amp;nbsp;the value '01/04/2019' is actually loaded into the target table&amp;nbsp;(i.e. no transformations are applied).&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 11:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575325#M162719</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T11:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575363#M162737</link>
      <description>&lt;P&gt;If you want to create a DATE value then you need to read your strings using a INFORMAT that generates a DATE value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN SUBSTR(PUT(FIELD_DATE,8.), 5, 4) = '0401'
THEN INPUT(SUBSTR(PUT(FIELD_DATE,8.), 1, 4) || '1127',yymmdd8.)
ELSE INPUT(SUBSTR(PUT(FIELD_DATE,8.), 1, 8),yymmdd8.) 
END as NEW_DATE_VARIABLE format=yymmdd10.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;At this point you have made three completely different claims about what type of data is in the variable FIELD_DATE.&lt;/P&gt;
&lt;P&gt;Your original post you claimed to have a DATE value (a number representing the number of days since 1960). Then you said it was a string with values like 27/11/2017 or perhaps like 20171127, which was not clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And now in this code you are telling us that instead FIELD_DATE is a numeric field with integers that LOOK like dates in YY,YYM,MDD format.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 13:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575363#M162737</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T13:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575376#M162742</link>
      <description>&lt;P&gt;&lt;BR /&gt;I am applying this code but it doesn't work, I don't get error messages but I obtain NULL values after the load process:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(PUT(FIELD_DATE,8.),5,4) = '0401'
THEN INPUT(SUBSTR(PUT(FIELD_DATE,8.),1,4) || '1127',yymmdd8.)
ELSE INPUT(SUBSTR(PUT(FIELD_DATE,8.),1,8),yymmdd8.)&lt;BR /&gt;END AS NEW_DATE_VARIABLE &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;yymmdd10. length = 8   
            format = DATE9.
            informat = DATE9.
            label = 'FIELD_DATE'&lt;/PRE&gt;&lt;P&gt;On the other hand, in my first example, the format in Teradata of FIELD_DATE was DATE (i.e. the source and target tables are defined with that type of format), as mentioned above. Then, I have checked that the&amp;nbsp;function mdy stressed by ChrisNZ works completely fine, as mentioned above. However, a major problem arises if the format of FIELD_TABLE in the source table is VARCHAR and I just questioned about this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575376#M162742</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T14:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575377#M162743</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282097"&gt;@George_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your explanation. I was playing with the functions INPUT and PUT to check the corresponding&amp;nbsp;conversion, because of the requirement of the SUBSTR function to work with a character argument in SAS, since I would like to use such a function to implement this transformation in SAS, if possible.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SUBSTR() works the same in most languages.&amp;nbsp; It takes part of a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to convert a DATE value to a string then use PUT() function with date format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put(field_date,yymmddn8.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to convert a string into a DATE value then use INPUT() function with a date informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input('20191127',yymmdd8.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575377#M162743</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T14:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575379#M162745</link>
      <description>&lt;P&gt;If it is a character string why are you treating it as if it was a number?&amp;nbsp; No need to use PUT() function to convert it to a string if it is already a string.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575379#M162745</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T14:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575381#M162747</link>
      <description>&lt;P&gt;I previously applied the following code without the PUT function, but I got the error message "Function SUBSTR requires a character expression as argument 1":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = '0401'&lt;BR /&gt;THEN SUBSTR(FIELD_DATE, 5, 4) || '1127'&lt;BR /&gt;ELSE SUBSTR(FIELD_DATE, 1, 8) END&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the specific definitions of the source and target tables in Teradata:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CREATE MULTISET TABLE DB.SOURCE_TABLE ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT,
     DEFAULT MERGEBLOCKRATIO
     (
      BUDGET VARCHAR(12) CHARACTER SET LATIN NOT CASESPECIFIC,
      FIELD_DATE VARCHAR(8) CHARACTER SET LATIN NOT CASESPECIFIC)
PRIMARY INDEX ( BUDGET );&lt;/PRE&gt;&lt;PRE&gt;CREATE MULTISET TABLE DB.TARGET_TABLE ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT,
     DEFAULT MERGEBLOCKRATIO
     (
      BUDGET VARCHAR(12) CHARACTER SET LATIN NOT CASESPECIFIC,
      FIELD_DATE DATE FORMAT 'YYYYMMDD')
PRIMARY INDEX ( BUDGET );&lt;/PRE&gt;&lt;P&gt;Thanks again for any help you can provide.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575381#M162747</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T14:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575390#M162750</link>
      <description>&lt;P&gt;If this is all in Teradata why are you even writing any SAS code?&lt;/P&gt;
&lt;P&gt;My teradata is rusty but something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;execute (
insert into target_table (source,field_date)
select source,cast(field_date) as date(0) format 'yyyymmdd'
from source_table
) by teradata;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have pulled the data into SAS then variable FIELD_DATE from SOURCE_TABLE is a character string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select source
     , case when (substr(field_date,1,4)='0401') then input(substr(field_date,1,4)||'1127',yymmdd8.)
            else input(field_date,yymmdd8.)
       end as field_date format=yymmdd10.
from source_table&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575390#M162750</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T14:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575402#M162752</link>
      <description>&lt;P&gt;I want to carry out this process with SAS Data Integration, I mentioned this detail in my first message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you mean that the process exceeds the capabilities of SAS? I just need to convert a value 'EP00YYYY' of a source table to the day 27 November YYYY of a target table, with the definitions above, just this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 15:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575402#M162752</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-22T15:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575410#M162755</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282097"&gt;@George_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to carry out this process with SAS Data Integration, I mentioned this detail in my first message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean that the process exceeds the capabilities of SAS? I just need to convert a value 'EP00YYYY' of a source table to the day 27 November YYYY of a target table, with the definitions above, just this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So if that is you actual problem?&lt;/P&gt;
&lt;P&gt;Then you should be able to tell DI that this is the rule for converting FIELD_DATE from source table into FIELD_DATE in target table.&lt;/P&gt;
&lt;P&gt;For example you could build a DATE9 style string from the last 4 characters in the EP00.... values and your constant day and month and then use the appropriate informat for the other values.&amp;nbsp; So if you strings look like 'DDMMYYYY' strings then use the DDMMYY informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when (field_date like 'EP00____') then input('27NOV'||substr(field_date,5,4),date9.)
  else input(field_date,ddmmyy8.) end format=yymmdd10.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575410#M162755</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T16:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575616#M162865</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I just need to convert a value 'EP00YYYY' of a source table to the day 27 November YYYY of a target table, with the definitions above, just this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Before getting stuck in the code, we need to solve this issue: How on earth does a Teradata VARCHAR variable arrive in SAS as a &lt;SPAN&gt;numeric variable&amp;nbsp;&lt;/SPAN&gt;(that gives you the &lt;SPAN&gt;"Function SUBSTR requires a character expression as argument 1" message)&amp;nbsp;&lt;/SPAN&gt;?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Until this is answered and solved, there is no point continuing as you'l never see the value &lt;STRONG&gt;EP00&lt;/STRONG&gt; that you are seeking in a numeric variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 23:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575616#M162865</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-22T23:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Concat substrings for dates in SAS-Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575723#M162914</link>
      <description>&lt;P&gt;I think I have solved the issue, since I realized that SAS Data Integration didn't totally upgrade the SAS code when registering the DB.SOURCE_TABLE within this program, which means a misunderstanding between the data flow shown within the program and the real code associated with the process. Specifically, I registered in SAS Data Integration the table&amp;nbsp;DB.SOURCE_TABLE&amp;nbsp;and joined it with the load process box. However,&amp;nbsp;I have checked that&amp;nbsp;the internal code didn't change at all and&amp;nbsp;was still&amp;nbsp;referring a DB.SOURCE_TABLE2 used in my first example (i.e. with a DATE format, instead of a VARCHAR format). I thought that these changes were automatically applied when you alter the schema, but it seems that only a few changes are applied and the reference to the source table in the INSERT FROM SELECT statement didn't actually change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this, I have applied the following code and it works completely fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE WHEN SUBSTR(FIELD_DATE, 1, 4) = 'EP00'
THEN INPUT(SUBSTR(FIELD_DATE, 5, 4) || '1127',YYMMDD8.)
ELSE INPUT(SUBSTR(FIELD_DATE, 1, 8),YYMMDD8.) END length = 8   
            format = YYMMDD8.
            informat = DATE9.
            label = 'FIELD_DATE'&lt;/PRE&gt;&lt;P&gt;Thank you so much ChrisNZ and Tom for helping me to solve this issue.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 10:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-substrings-for-dates-in-SAS-Teradata/m-p/575723#M162914</guid>
      <dc:creator>George_SAS</dc:creator>
      <dc:date>2019-07-23T10:26:08Z</dc:date>
    </item>
  </channel>
</rss>

