<?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: Length of character variable of Teradata table in SAS in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506349#M15715</link>
    <description>&lt;P&gt;Dear Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for sharing this option with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will play around with it. I was wondering if this will apply to Teradata as&amp;nbsp;the documentation says&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Data source:&lt;/TD&gt;&lt;TD&gt;Oracle&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree with you on "&lt;SPAN&gt;any non-standard (non 7bit) ASCII codes in your LATIN1 data will take more than one byte to store in the SAS variable&lt;/SPAN&gt;". At least for the columns that I create using LATIN I know the variable is ASCII and can fit in 7 bits.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Oct 2018 05:39:43 GMT</pubDate>
    <dc:creator>Shakir_Juolay</dc:creator>
    <dc:date>2018-10-22T05:39:43Z</dc:date>
    <item>
      <title>Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504620#M15667</link>
      <description>&lt;P&gt;I have created a Teradata table as below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create multiset table d_test.test_char_length (
    contract_id int
   ,var1 varchar(5) character set latin
   ,var2 varchar(5) character set unicode
)unique primary index(contract_id)
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Inserted a dummy row as below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;insert into d_test.test_char_length values (123,'home','home');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Below is the SAS code to read the Teradata table and PROC CONTENTS on the&amp;nbsp;table in Teradata and in SAS.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_char_length;
    set d_test.test_char_length;
run;

proc contents data=d_test.test_char_length;
run;

proc contents data=test_char_length;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Below is the output&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                                                                 10:14 Tuesday, October 16, 2018   1

                                                       The CONTENTS Procedure

                              Data Set Name        D_TEST.test_char_length    Observations          . 
                              Member Type          DATA                       Variables             3 
                              Engine               TERADATA                   Indexes               0 
                              Created              .                          Observation Length    0 
                              Last Modified        .                          Deleted Observations  0 
                              Protection                                      Compressed            NO
                              Data Set Type                                   Sorted                NO
                              Label                                                                   
                              Data Representation  Default                                            
                              Encoding             Default                                            


                                             Alphabetic List of Variables and Attributes
 
                                #    Variable       Type    Len    Format    Informat    Label

                                1    contract_id    Num       8    11.       11.         contract_id
                                2    var1           Char     10    $10.      $10.        var1       
                                3    var2           Char     15    $15.      $15.        var2       
                                                                                                 10:14 Tuesday, October 16, 2018   2

                                                       The CONTENTS Procedure

               Data Set Name        WORK.TEST_CHAR_LENGTH                                    Observations          1 
               Member Type          DATA                                                     Variables             3 
               Engine               V9                                                       Indexes               0 
               Created              10/16/2018 10:22:00                                      Observation Length    40
               Last Modified        10/16/2018 10:22:00                                      Deleted Observations  0 
               Protection                                                                    Compressed            NO
               Data Set Type                                                                 Sorted                NO
               Label                                                                                                 
               Data Representation  SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64                            
               Encoding             utf-8  Unicode (UTF-8)                                                           


                                                 Engine/Host Dependent Information

  Data Set Page Size          65536                                                                                               
  Number of Data Set Pages    1                                                                                                   
  First Data Page             1                                                                                                   
  Max Obs per Page            1632                                                                                                
  Obs in First Data Page      1                                                                                                   
  Number of Data Set Repairs  0                                                                                                   
  Filename                    /saswork/SAS_work0E0F00005108_sas-compute/SAS_workD74B00005108_sas-compute/test_char_length.sas7bdat
  Release Created             9.0401M4                                                                                            
  Host Created                Linux                                                                                               
  Inode Number                4063249                                                                                             
  Access Permission           rw-r--r--                                                                                           
  Owner Name                  unxsrv                                                                                              
  File Size                   128KB                                                                                               
  File Size (bytes)           131072                                                                                              


                                             Alphabetic List of Variables and Attributes
 
                                #    Variable       Type    Len    Format    Informat    Label

                                1    contract_id    Num       8    11.       11.         contract_id
                                2    var1           Char     10    $10.      $10.        var1       
                                3    var2           Char     15    $15.      $15.        var2       &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My question is why the length of var1 (LATIN encoding in Teradata) in SAS is 10 instead of 5 and var2&lt;SPAN&gt;&amp;nbsp;(UNICODE encoding in Teradata)&lt;/SPAN&gt; is 15 instead of 5. I was expecting var1 to be 5 and var2 to be 10 in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shakir&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504620#M15667</guid>
      <dc:creator>Shakir_Juolay</dc:creator>
      <dc:date>2018-10-16T07:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504626#M15669</link>
      <description>&lt;P&gt;Look at the contents of var1 and var2 with $hex20. and $hex30., respectively. You might find surprising things in there.&lt;/P&gt;
&lt;P&gt;My guess:&lt;/P&gt;
&lt;P&gt;SAS recodes the latin to UTF-16 for var1, and keeps UTF-8 (which may need more than 2 bytes per character) for var2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504626#M15669</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T07:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504637#M15670</link>
      <description>&lt;P&gt;This is what I did&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_char_length;
    set d_dmin.test_char_length;
    put var1 $10.;
    put var1 $hex20.;
    put var2 $15.;
    put var2 $hex30.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the log&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;15         data test_char_length;
16             set d_dmin.test_char_length;
17             put var1 $10.;
18             put var1 $hex20.;
19             put var2 $15.;
20             put var2 $hex30.;
21         run;

home      
686F6D65202020202020
home           
686F6D652020202020202020202020
NOTE: There were 1 observations read from the data set D_DMIN.test_char_length.
NOTE: The data set WORK.TEST_CHAR_LENGTH has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.03 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also this post &lt;A href="https://community.teradata.com/t5/Database/UTF-8-or-UTF-16/m-p/61680" target="_self"&gt;https://community.teradata.com/t5/Database/UTF-8-or-UTF-16/m-p/61680&lt;/A&gt;&amp;nbsp;says unicode in Teradata is always UTF-16.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible in SAS for one column to be LATIN and another one to be UTF8 or UTF16 in the same Table.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504637#M15670</guid>
      <dc:creator>Shakir_Juolay</dc:creator>
      <dc:date>2018-10-16T08:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504649#M15671</link>
      <description>&lt;P&gt;Also can we somehow configure SAS and/or Teradata Client on the SAS server, so that for var1 the length in SAS is 5, since its LATIN and 1 byte per character is enough for LATIN.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 09:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504649#M15671</guid>
      <dc:creator>Shakir_Juolay</dc:creator>
      <dc:date>2018-10-16T09:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504657#M15673</link>
      <description>&lt;P&gt;So you have UTF-8 encoding all the way through.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mind that SAS keeps encoding on a file/dataset and not a column level. You can see that in your proc contents output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My final guess: SAS tries to "play it safe" with regards to defined lengths; if that does not work for you, you will have to override that, either by setting lengths explicitly, or by trying to work with &lt;FONT face="courier new,courier"&gt;dbsastype&lt;/FONT&gt; options.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 10:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/504657#M15673</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T10:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506293#M15713</link>
      <description>&lt;P&gt;Dear Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see what you mean by&amp;nbsp;&lt;SPAN&gt;SAS tries to "play it safe" with regards to defined lengths. There was a gap in my understanding of UTF-8 and how many bytes are used by it for storage. When I read the Efficiency section of&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Comparison_of_Unicode_encodings" target="_blank"&gt;https://en.wikipedia.org/wiki/Comparison_of_Unicode_encodings&lt;/A&gt; I see that characters with code points with 8 bits i.e. U+0080 to&amp;nbsp;U+00FF are stored in UTF-8 in 2 bytes and not one. And characters with code points with 16 bits are stored with 3 bytes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Teradata LATIN CHAR(&lt;STRONG&gt;n&lt;/STRONG&gt;) needs &lt;STRONG&gt;8 bits per n&lt;/STRONG&gt; hence in SAS UTF-8 the length becomes &lt;STRONG&gt;2n&lt;/STRONG&gt;, and Teradata UNICODE CHAR(&lt;STRONG&gt;n&lt;/STRONG&gt;) needs &lt;STRONG&gt;16 bits per n&lt;/STRONG&gt; hence in SAS UTF-8 the length becomes &lt;STRONG&gt;3n&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now I store English characters in Teradata&amp;nbsp;LATIN which only need 7 bits so I can use &lt;STRONG&gt;dbsastype&lt;/STRONG&gt;&amp;nbsp;to change&amp;nbsp;Teradata LATIN CHAR(&lt;STRONG&gt;n&lt;/STRONG&gt;) to&amp;nbsp;SAS UTF-8&amp;nbsp;length &lt;STRONG&gt;n&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I use&amp;nbsp;Teradata&amp;nbsp;UNICODE only for Arabic characters, which fit in UTF-8 with 16 bits&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;so I can use&amp;nbsp;&lt;STRONG&gt;dbsastype&lt;/STRONG&gt;&amp;nbsp;to change&amp;nbsp;Teradata UNICODE&amp;nbsp;CHAR(&lt;STRONG&gt;n&lt;/STRONG&gt;) to&amp;nbsp;SAS UTF-8&amp;nbsp;length&amp;nbsp;&lt;STRONG&gt;2n&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It appears using &lt;STRONG&gt;dbsastype&lt;/STRONG&gt;, I will have to do column by column, is there a universal SAS OPTION to do all columns together? Else I write a SAS macro leveraging Teradata dictionary under DB &lt;STRONG&gt;DBC.*&lt;/STRONG&gt;&amp;nbsp;and &lt;STRONG&gt;dbsastype&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank You Kurt.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Oct 2018 05:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506293#M15713</guid>
      <dc:creator>Shakir_Juolay</dc:creator>
      <dc:date>2018-10-21T05:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506342#M15714</link>
      <description>&lt;P&gt;There are settings that do help tell SAS how to automatically adjust lengths to allow room for transcoding of characters.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=acreldb&amp;amp;docsetTarget=n1n4y3nxgpi50vn1m0walgenlwm6.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=acreldb&amp;amp;docsetTarget=n1n4y3nxgpi50vn1m0walgenlwm6.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you want a specific behavior then you will need to code your own logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that just because your Teradata column is using LATIN1 it does not mean that your SAS variable can store the value in the same number of bytes.&amp;nbsp; In SAS you cannot have one variable using one encoding and another using a different encoding. So if you want to read your UTF8 data then SAS will need to use UTF8 for your dataset. That means that any non-standard (non 7bit) ASCII codes in your LATIN1 data will take more than one byte to store in the SAS variable.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 00:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506342#M15714</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-22T00:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Length of character variable of Teradata table in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506349#M15715</link>
      <description>&lt;P&gt;Dear Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for sharing this option with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will play around with it. I was wondering if this will apply to Teradata as&amp;nbsp;the documentation says&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Data source:&lt;/TD&gt;&lt;TD&gt;Oracle&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree with you on "&lt;SPAN&gt;any non-standard (non 7bit) ASCII codes in your LATIN1 data will take more than one byte to store in the SAS variable&lt;/SPAN&gt;". At least for the columns that I create using LATIN I know the variable is ASCII and can fit in 7 bits.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 05:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Length-of-character-variable-of-Teradata-table-in-SAS/m-p/506349#M15715</guid>
      <dc:creator>Shakir_Juolay</dc:creator>
      <dc:date>2018-10-22T05:39:43Z</dc:date>
    </item>
  </channel>
</rss>

