<?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: PROC IMPORT CSV character value instead of numeric value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884365#M349380</link>
    <description>&lt;P&gt;Proc Import for text files such as CSV will create data step code. Look in your log.&lt;/P&gt;
&lt;P&gt;You can copy that generated code, paste it into the editor, clean&amp;nbsp; it up a bit (remove line numbers) and then change the properties of the variables by changing the Informat statement generated for your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you are going to read multiple files with the same structure I would suggest saving that data step and likely making character variables 5 to 10 characters longer to accommodate other data files with longer values. Then you just modify the Infile statement to point to the new source file and change the output data set name as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on your data you might also consider cleaning up variable names and adding labels to variables.&lt;/P&gt;
&lt;P&gt;You can likely drop most of the Format statements accept for date, time or datetime values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2023 16:43:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-07-11T16:43:30Z</dc:date>
    <item>
      <title>PROC IMPORT CSV character value instead of numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884344#M349364</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I imported a csv file with the following code :&lt;/P&gt;&lt;P&gt;proc import out=GSM&lt;BR /&gt;datafile='V:\3613_DEPT_CONTROLE_DE_GESTION\Transverse\ANAPLAN\PALLIATIFS_DIRECT_PBI\commissions\GSM.csv'&lt;BR /&gt;DBMS=csv&lt;BR /&gt;replace;&lt;BR /&gt;delimiter = ";";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the GSM.csv file, one column is "Comax Code" and the format is character. For example, "0000001"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS put automatically an informat : numeric and "0000001" become the number 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To fix that I try :&lt;/P&gt;&lt;P&gt;proc import out=GSM&lt;BR /&gt;datafile='V:\3613_DEPT_CONTROLE_DE_GESTION\Transverse\ANAPLAN\PALLIATIFS_DIRECT_PBI\commissions\GSM.csv'&lt;BR /&gt;DBMS=csv&lt;BR /&gt;replace;&lt;BR /&gt;delimiter = ";";&lt;BR /&gt;informat "Comax Code" $8.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I still have the wrong informat :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaroleBPRI_0-1689086533156.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85719i272B64C58C44266A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CaroleBPRI_0-1689086533156.png" alt="CaroleBPRI_0-1689086533156.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 14:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884344#M349364</guid>
      <dc:creator>CaroleBPRI</dc:creator>
      <dc:date>2023-07-11T14:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT CSV character value instead of numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884348#M349367</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use DATA step to read&amp;nbsp; a csv file. You cannot control over the format in PROC IMPORT.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 14:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884348#M349367</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-07-11T14:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT CSV character value instead of numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884355#M349373</link>
      <description>&lt;P&gt;You can consider changing wihtthe data step following Proc iMport:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc import out=GSM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datafile='V:\3613_DEPT_CONTROLE_DE_GESTION\Transverse\ANAPLAN\PALLIATIFS_DIRECT_PBI\commissions\GSM.csv'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DBMS=csv&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;replace;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;delimiter = ";";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Data GSM;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; set GSM(rename=(ComaxCode=CC));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; ComaxCode=put(CC,z7.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;drop cc;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 15:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884355#M349373</guid>
      <dc:creator>john_mccall</dc:creator>
      <dc:date>2023-07-11T15:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT CSV character value instead of numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884365#M349380</link>
      <description>&lt;P&gt;Proc Import for text files such as CSV will create data step code. Look in your log.&lt;/P&gt;
&lt;P&gt;You can copy that generated code, paste it into the editor, clean&amp;nbsp; it up a bit (remove line numbers) and then change the properties of the variables by changing the Informat statement generated for your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you are going to read multiple files with the same structure I would suggest saving that data step and likely making character variables 5 to 10 characters longer to accommodate other data files with longer values. Then you just modify the Infile statement to point to the new source file and change the output data set name as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on your data you might also consider cleaning up variable names and adding labels to variables.&lt;/P&gt;
&lt;P&gt;You can likely drop most of the Format statements accept for date, time or datetime values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 16:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-CSV-character-value-instead-of-numeric-value/m-p/884365#M349380</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-07-11T16:43:30Z</dc:date>
    </item>
  </channel>
</rss>

