<?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: Table created does not have the same length, informat and format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389051#M93288</link>
    <description>&lt;P&gt;I checked with my senior and what he said is exactly what you posted. Thanks for the reply. I used your method 1 and now it is working perfectly with my expected result sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed a few places to assign length format informat to macro array and include it in the %if in the last proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again thanks alot.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2017 07:14:56 GMT</pubDate>
    <dc:creator>imdickson</dc:creator>
    <dc:date>2017-08-18T07:14:56Z</dc:date>
    <item>
      <title>Table created does not have the same length, informat and format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389031#M93280</link>
      <description>&lt;P&gt;Hello Everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have my code to create target table based on source table. However, Table created does not have the same length, informat and format. The thing is, this is a macro code and it will generate 30 tables. I look at the table 1 by 1 and found out 3 out of 30 are not having the same length, informat and format. The rest of the 27 tables are getting the same exact attributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table
 CDSSTG.&amp;amp;targettblnm as(
 select
%let comma =;
%let null=;
%let case2=case;
%let comma2=,;
%let one=1;
%let two=2;
%let previous=;
%let nothing =;
/*proc sql noprint; */
/*create table &amp;amp;targettblnm as(*/
	%do k=1 %to &amp;amp;cwcount;
	%if "&amp;amp;previous" ne "&amp;amp;&amp;amp;cwcolumn&amp;amp;k.." %then %do;
	%let tamat=end;
	%end;
	%else %do;
	%let tamat=;
	%end;
	/*first condition is to change unit only*/
	%if "&amp;amp;previous" ne "&amp;amp;&amp;amp;cwcolumn&amp;amp;k.." %then %do;
	%let tamat=end;
	%end;
	%else %do;
	%let tamat=;
	%end;
	%if "&amp;amp;&amp;amp;cwuomto&amp;amp;k.." ne "&amp;amp;null" %then %do;
/*		%put &amp;amp;tamat. */
	&amp;amp;comma case when &amp;amp;&amp;amp;cwcolumn&amp;amp;k.. ne %squote(&amp;amp;&amp;amp;cwuomto&amp;amp;k..) then %squote(&amp;amp;&amp;amp;cwuomto&amp;amp;k..) 
		else %squote(&amp;amp;&amp;amp;cwuomto&amp;amp;k..) end as &amp;amp;&amp;amp;cwcolumn&amp;amp;k..
	%end;
	/*second condition is to convert based on formula*/

	%else %if "&amp;amp;&amp;amp;cwsourceuomname&amp;amp;k.." ne "&amp;amp;null" and "&amp;amp;&amp;amp;cwdefaultflag&amp;amp;k.." eq "&amp;amp;one" %then %do;

/*		%put */
	&amp;amp;comma case when &amp;amp;&amp;amp;cwsourceuomname&amp;amp;k.. = %squote(&amp;amp;&amp;amp;cwto&amp;amp;k..) then &amp;amp;&amp;amp;cwcolumn&amp;amp;k..

		
		
	%end;

	%else %if "&amp;amp;&amp;amp;cwsourceuomname&amp;amp;k.." ne "&amp;amp;null" and "&amp;amp;&amp;amp;cwdefaultflag&amp;amp;k.." eq "&amp;amp;two" and "&amp;amp;&amp;amp;cwendflag&amp;amp;k.." ne "&amp;amp;one" %then %do;
		 
		when &amp;amp;&amp;amp;cwsourceuomname&amp;amp;k.. = %squote(&amp;amp;&amp;amp;cwfrom&amp;amp;k..) then &amp;amp;&amp;amp;cwcolumn&amp;amp;k * &amp;amp;&amp;amp;cwformula&amp;amp;k..
	%end;
		%else %if "&amp;amp;&amp;amp;cwsourceuomname&amp;amp;k.." ne "&amp;amp;null" and "&amp;amp;&amp;amp;cwdefaultflag&amp;amp;k.." eq "&amp;amp;two" and "&amp;amp;&amp;amp;cwendflag&amp;amp;k.." eq "&amp;amp;one" %then %do;
		 
	when &amp;amp;&amp;amp;cwsourceuomname&amp;amp;k.. = %squote(&amp;amp;&amp;amp;cwfrom&amp;amp;k..) then &amp;amp;&amp;amp;cwcolumn&amp;amp;k * &amp;amp;&amp;amp;cwformula&amp;amp;k.. end as &amp;amp;&amp;amp;cwcolumn&amp;amp;k
	%end;
	%else %do;
	 
	&amp;amp;comma &amp;amp;&amp;amp;cwcolumn&amp;amp;k..
	%end;
	%let comma=,;
	%let previous=&amp;amp;&amp;amp;cwcolumn&amp;amp;k..;


	%end;
	 from CDSSTG.&amp;amp;sourcetblnm);
	quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is a SQL with some logics in. The logics is working fine and perfectly but only 3 out of 30 tables do not have the same attributes as the source table. Do i actually missed out some important steps? Why is it only 3 tables are affected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 03:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389031#M93280</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-08-18T03:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Table created does not have the same length, informat and format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389033#M93281</link>
      <description>&lt;P&gt;Because your variables are calculated in SQL (in the case statement), the length has to be guessed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 ways you can&amp;nbsp;force the lengths:&lt;/P&gt;
&lt;P&gt;- add a &lt;FONT face="courier new,courier"&gt;length&lt;/FONT&gt;= parameter in your select statement, like this: &amp;nbsp; &lt;FONT face="courier new,courier"&gt;case ... end as VAR length=&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;- create the table first:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;create table TAB2 like TAB1&amp;nbsp;&lt;/FONT&gt;and then insert into that table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 04:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389033#M93281</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-08-18T04:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Table created does not have the same length, informat and format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389051#M93288</link>
      <description>&lt;P&gt;I checked with my senior and what he said is exactly what you posted. Thanks for the reply. I used your method 1 and now it is working perfectly with my expected result sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed a few places to assign length format informat to macro array and include it in the %if in the last proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again thanks alot.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 07:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-created-does-not-have-the-same-length-informat-and-format/m-p/389051#M93288</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-08-18T07:14:56Z</dc:date>
    </item>
  </channel>
</rss>

