<?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: Formating in SQL in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461523#M29758</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;Agree, In fact my actual values are only 12 digits and just for an example I gave max value as 20. Sorry for the miss communication.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 May 2018 12:19:33 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-05-11T12:19:33Z</dc:date>
    <item>
      <title>Formating in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461277#M29739</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to load a data table off teradata in SAS and some of the formats of the variables were incompatible. I got around this by doing cast(var1 as varchar(8))&amp;nbsp; but I had to do this for each variable. Is there a way to change multiple variables formats with one function with SQL on Teradata?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 10:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461277#M29739</guid>
      <dc:creator>Scott86</dc:creator>
      <dc:date>2018-05-10T10:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Formating in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461305#M29744</link>
      <description>&lt;P&gt;Character values might not have any issues. SAS will apply default behavior for the datatypes (&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a001384390.htm" target="_self"&gt;Check here&lt;/A&gt;). If you want the datatypes then you need to convert them from teradata side. Recently I came across where numeric values&lt;SPAN&gt;(Like 1234567891234)&lt;/SPAN&gt; are defined in teradata as Float, SAS reads them as 8. format where I need format like 20. In this case in my pass-through I defined as&amp;nbsp;&lt;STRONG&gt;CAST(t2.CUSTOMER_ID as decimal(20,0)) as CUSTOMER_ID &lt;/STRONG&gt;(Note: IF teradata format is&amp;nbsp;&lt;STRONG&gt;DECIMAL(&lt;SPAN class="emph"&gt;n&lt;/SPAN&gt;,&amp;nbsp;&lt;SPAN class="emph"&gt;m&lt;/SPAN&gt;&amp;nbsp;)&lt;/STRONG&gt; then SAS default will be&lt;STRONG&gt;&amp;nbsp;(&lt;SPAN class="emph"&gt;n&lt;/SPAN&gt;+2 ).(&lt;SPAN class="emph"&gt;m&lt;/SPAN&gt;&amp;nbsp;)&lt;/STRONG&gt; ). So SAS will have format 22.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First thing you need to do is find out the format associated in teradata. For this you can query the DBC.COLUMNS in teradata. Then if you want to convert the datatypes using CAST for multiple columns then you can create a macro from the table created from DBC.COLUMNS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL ;
CONNECT TO TERADATA AS MYCON(SERVER=   Authdomain= );
CREATE TABLE _Info AS 
SELECT *
	FROM CONNECTION TO MYCON
		(

SELECT TRIM(ColumnName) AS "ColumnName", 
		ColumnType 
	FROM DBC.COLUMNS 
		WHERE TableName = 'myteradata'
			);
DISCONNECT FROM MYCON;
QUIT;
PROC SQL;
select CASE 
	WHEN ColumnType='FLOAT' then CAT('CAST(',ColumnName,'as decimal(20,0)) as',ColumnName)
	ELSE ColumnName END as Convert_Name INTO: New_Colums_Needed separated by ','
from _Info;
quit;

PROC SQL ;
CONNECT TO TERADATA AS MYCON(SERVER=   Authdomain= );
CREATE TABLE _Info AS 
SELECT *
	FROM CONNECTION TO MYCON
		(

SELECT &amp;amp;New_Colums_Needed.
	FROM myteradtata 
		
			);
DISCONNECT FROM MYCON;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is just an approach and I didn't test. Use your datatypes that you wish to convert with proper function and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 12:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461305#M29744</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-10T12:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Formating in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461517#M29757</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83078"&gt;@SuryaKiran&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You'd better cast such a customer_id to a CHAR or VARCHAR as SAS 9.4 uses only 8 Bytes to store numbers and you can't store 20 digits with full precision. You certainly don't want to end up with altered customer_id's in SAS.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 11:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461517#M29757</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-11T11:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Formating in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461523#M29758</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;Agree, In fact my actual values are only 12 digits and just for an example I gave max value as 20. Sorry for the miss communication.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 12:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Formating-in-SQL/m-p/461523#M29758</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-11T12:19:33Z</dc:date>
    </item>
  </channel>
</rss>

