<?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 SAS automatically reassign format for all columns in a table in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-automatically-reassign-format-for-all-columns-in-a-table/m-p/378886#M24655</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input @1 number $char1. 
        @3 date $char10.;
  datalines;
1 01/01/1990
2 02/02/1992
;
run;

data want;
  input @1 number best1. 
        @3 date DDMMYY10.;
  format date date9.;
  datalines;
1 01/01/1990
2 02/02/1992
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Codes above to generate datasets 'have' and 'want'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following codes can be used to &lt;SPAN&gt;explicitly reassign the format of those two columns:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data target;
set have;

format temp1 best1.; temp1 = input(number,best8.); drop number; rename temp1=number;
format temp2 date9.; temp2 = input(date, ANYDTDTE10.); drop date; rename temp2=date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;However, is there a way to ask SAS to automatically reassign formats for all columns in a table?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. with the Import Wizard, SAS EG can assign a default Type, Len. etc. (depending whether the column has only numbers, or date values).&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2017 07:21:48 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-07-25T07:21:48Z</dc:date>
    <item>
      <title>SAS automatically reassign format for all columns in a table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-automatically-reassign-format-for-all-columns-in-a-table/m-p/378886#M24655</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input @1 number $char1. 
        @3 date $char10.;
  datalines;
1 01/01/1990
2 02/02/1992
;
run;

data want;
  input @1 number best1. 
        @3 date DDMMYY10.;
  format date date9.;
  datalines;
1 01/01/1990
2 02/02/1992
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Codes above to generate datasets 'have' and 'want'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following codes can be used to &lt;SPAN&gt;explicitly reassign the format of those two columns:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data target;
set have;

format temp1 best1.; temp1 = input(number,best8.); drop number; rename temp1=number;
format temp2 date9.; temp2 = input(date, ANYDTDTE10.); drop date; rename temp2=date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;However, is there a way to ask SAS to automatically reassign formats for all columns in a table?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. with the Import Wizard, SAS EG can assign a default Type, Len. etc. (depending whether the column has only numbers, or date values).&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 07:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-automatically-reassign-format-for-all-columns-in-a-table/m-p/378886#M24655</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-07-25T07:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS automatically reassign format for all columns in a table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-automatically-reassign-format-for-all-columns-in-a-table/m-p/378894#M24659</link>
      <description>&lt;P&gt;Well, the problem with your methodology would be what default to apply. &amp;nbsp;Numbers could be anything from 16 to 1, include signs and decimals. &amp;nbsp;Characters can contain anything and be up to 2000 long, and dates can come in any number of formats (and could be char or number). &amp;nbsp;So the quesiton is how are you going to standardise all this? &amp;nbsp;What are your rules? &amp;nbsp;What are the error capture necessities etc. &amp;nbsp;Techinically it is possible to generate the necessary program, however you need to have all your rules in place and for them to cover every eventuality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A more pertinent question is why do you not know what your data is like? &amp;nbsp;Why the need to change formats and such like after the event, sounds like something earlier in the process is not working, maybe your importing from Excel (as Excel is a poor data medium) and using proc import (a guessing procedure, multiplies the issues you will have with Excel). &amp;nbsp;So a solution there would be to use a robust data medium (CSV, XML etc.) and write a datastep import program to specifically import the data into the model you need.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 07:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-automatically-reassign-format-for-all-columns-in-a-table/m-p/378894#M24659</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-25T07:56:21Z</dc:date>
    </item>
  </channel>
</rss>

