<?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: how to change the variable format during a proc import in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986833#M46476</link>
    <description>&lt;P&gt;If you want to import a variable as character rather than numeric from a CSV file, you have several options:&lt;/P&gt;
&lt;P&gt;1. PROC IMPORT determines a variable's type by the first 20 rows. Add a dummy first row that has a character value for the desired variable.&lt;/P&gt;
&lt;P&gt;2. Import ALL variables as character by adding the following statement before PROC IMPORT:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let EFI_ALLCHARS=YES;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Recall the DATA Step code that is run behind the scenes and then modify the INPUT, INFORMAT, and FORMAT statements for the desired variable.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2026 15:50:37 GMT</pubDate>
    <dc:creator>Kathryn_SAS</dc:creator>
    <dc:date>2026-04-27T15:50:37Z</dc:date>
    <item>
      <title>how to change the variable format during a proc import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986821#M46475</link>
      <description>&lt;P&gt;Is there a way to modify a variable format from numeric to string&amp;nbsp;using proc import ?&lt;BR /&gt;If so please provide an example.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out=bandep.&amp;amp;co._auto_prm&amp;amp;moisc.&amp;amp;year._&amp;amp;suffix1.
     datafile="&amp;amp;prefix3/&amp;amp;co./&amp;amp;co._auto_prm&amp;amp;moisc.&amp;amp;year..csv"    
     DBMS=CSV
     REPLACE;
     DELIMITER='|';
     GETNAMES=YES;
     GUESSINGROWS=MAX;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2026 14:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986821#M46475</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2026-04-27T14:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the variable format during a proc import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986833#M46476</link>
      <description>&lt;P&gt;If you want to import a variable as character rather than numeric from a CSV file, you have several options:&lt;/P&gt;
&lt;P&gt;1. PROC IMPORT determines a variable's type by the first 20 rows. Add a dummy first row that has a character value for the desired variable.&lt;/P&gt;
&lt;P&gt;2. Import ALL variables as character by adding the following statement before PROC IMPORT:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let EFI_ALLCHARS=YES;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Recall the DATA Step code that is run behind the scenes and then modify the INPUT, INFORMAT, and FORMAT statements for the desired variable.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2026 15:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986833#M46476</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2026-04-27T15:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the variable format during a proc import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986838#M46477</link>
      <description>Can you provide a SAS code example because I not famillar with %let EFI_ALLCHAR=yes;</description>
      <pubDate>Mon, 27 Apr 2026 16:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986838#M46477</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2026-04-27T16:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the variable format during a proc import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986839#M46478</link>
      <description>&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create a csv file of the sashelp.class data set */
ods listing close;
ods csv file='c:\temp\class.csv';

proc print data=sashelp.class noobs;
run;

ods csv close;
ods listing;

%let EFI_ALLCHARS=yes;
proc import datafile='c:\temp\class.csv'
 out=class dbms=csv replace;
run;

proc contents data=class;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2026 16:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986839#M46478</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2026-04-27T16:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the variable format during a proc import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986843#M46479</link>
      <description>&lt;P&gt;Easiest answer is to skip PROC IMPORT and just write the data step to read the file yourself.&lt;/P&gt;
&lt;P&gt;It is really not that hard and in fact the code might actually be easier than the code to write PROC IMPORT.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bandep.&amp;amp;co._auto_prm&amp;amp;moisc.&amp;amp;year._&amp;amp;suffix1.;
  infile "&amp;amp;prefix3/&amp;amp;co./&amp;amp;co._auto_prm&amp;amp;moisc.&amp;amp;year..csv" 
    dsd truncover firstobs=2 dlm='|';
  length var1 var2 var3 var4 8 var5 $10 var6 $5 ;
  input var1--var6;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you do need a tool that can GUESS how to define the variables, but also allow you to override those decisions you could use this macro instead:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_self"&gt;%csv2ds()&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say you had the same 6 column CSV file as implied by the first example code above and you wanted to force the fifth variable to be character with length of 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data override;
  varnum=5;
  length='$10';
  informat=' ';
  format=' ';
run;
%csv2ds
(out=bandep.&amp;amp;co._auto_prm&amp;amp;moisc.&amp;amp;year._&amp;amp;suffix1.
,filen="&amp;amp;prefix3/&amp;amp;co./&amp;amp;co._auto_prm&amp;amp;moisc.&amp;amp;year..csv"
,dlm='|'
,replace=1
,overrides=override
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2026 17:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986843#M46479</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-04-27T17:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the variable format during a proc import</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986920#M46480</link>
      <description>When reading text files, don‘t waste your time with PROC IMPORT. Write the DATA step yourself, according to the documentation of the file.&lt;BR /&gt;You‘ll get much cleaner and easier to maintain code, and have the full flexibility if DATA step coding at your hand.&lt;BR /&gt;The accepted solution will make it impossible to correctly read numeric values, including dates and times.</description>
      <pubDate>Tue, 28 Apr 2026 18:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-change-the-variable-format-during-a-proc-import/m-p/986920#M46480</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2026-04-28T18:09:49Z</dc:date>
    </item>
  </channel>
</rss>

