<?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: CSV file to SAS import issues in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876127#M346181</link>
    <description>I've deleted your code/data. You can feel free to edit your posts yourself, click the three lines beside the post and edit.</description>
    <pubDate>Tue, 16 May 2023 23:01:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-05-16T23:01:30Z</dc:date>
    <item>
      <title>CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/875953#M346106</link>
      <description>&lt;P&gt;Hi, I need to import a csv data (sample observations and variables attached) to SAS. I am using the below code and imported the data but couldn't solve a few issues I am having:&lt;/P&gt;
&lt;P&gt;1. SAS read many of the character variables as single length (screenshot of the out put attached) which I couldn't increase applying informat, attrib or length functions.&lt;/P&gt;
&lt;P&gt;2. Although the dataset is created with all the above issues, I am still getting error message in the log saying: "ERROR: Import unsuccessful. See SAS Log for details."&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc import datafile="C:\Sample3.csv"
dbms=csv  
out=Sample3; 
getnames=yes;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 497px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84008iF52BDB1B088E9918/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 23:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/875953#M346106</guid>
      <dc:creator>Wub_SAS</dc:creator>
      <dc:date>2023-05-16T23:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876086#M346165</link>
      <description>This includes your actual data, did you intend to include that?</description>
      <pubDate>Tue, 16 May 2023 20:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876086#M346165</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-16T20:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876108#M346169</link>
      <description>&lt;P&gt;By default Proc Import only examines 20 rows of data to set properties. If a "column" doesn't have any values in the first 20 rows then SAS sets a width of 1 and makes the column character.&lt;/P&gt;
&lt;P&gt;Use the GUESSINROWS statement to tell SAS how many rows to read to set properties.&lt;/P&gt;
&lt;PRE&gt;proc import datafile="C:\Sample3.csv"
dbms=csv  
out=Sample3; 
getnames=yes;
guessingrows=max;
run;&lt;/PRE&gt;
&lt;P&gt;Better if you have a an actual description of the file contents is to use that information to write a data step.&lt;/P&gt;
&lt;P&gt;Import will attempt to treat a field with all digits as a numeric value which means that significant leading zeroes, such as appear in account information in many sources, get discarded. When Proc Import "reads" different data files that should have the same properties you can get different lengths and sometimes variable types which leads to problems when combining data sets.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 21:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876108#M346169</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-16T21:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876111#M346171</link>
      <description>&lt;P&gt;Make to to tell SAS to check the WHOLE file before determining the type/length to GUESS for the variables.&lt;/P&gt;
&lt;P&gt;Add this statement to the PROC IMPORT step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;guessingrows=max;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your data step you are telling SAS to use COMMA as the delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data WORK.SAMPLE3;
  infile datalines dsd truncover;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But your in-line data lines do NOT have commas as the delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact they don't appear to have any delimiter.&amp;nbsp; If the delimiter is a TAB then DO NOT use in-line data.&amp;nbsp; Normal SAS will replace the tabs with spaces when you submit the code.&amp;nbsp; Or is the data in fixed column locations instead?&amp;nbsp; In that case you need to use a different style of INPUT statement.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 21:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876111#M346171</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-16T21:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876121#M346177</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;. No, I picked the wrong dataset. I contacted asked to get help for this post to be deleted so that can re-post with the correct sample dataset.</description>
      <pubDate>Tue, 16 May 2023 22:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876121#M346177</guid>
      <dc:creator>Wub_SAS</dc:creator>
      <dc:date>2023-05-16T22:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876127#M346181</link>
      <description>I've deleted your code/data. You can feel free to edit your posts yourself, click the three lines beside the post and edit.</description>
      <pubDate>Tue, 16 May 2023 23:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876127#M346181</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-16T23:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876137#M346184</link>
      <description>Thank you for the help! &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;.</description>
      <pubDate>Wed, 17 May 2023 00:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876137#M346184</guid>
      <dc:creator>Wub_SAS</dc:creator>
      <dc:date>2023-05-17T00:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876138#M346185</link>
      <description>Thanks a lot! That was very helpful.</description>
      <pubDate>Wed, 17 May 2023 00:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876138#M346185</guid>
      <dc:creator>Wub_SAS</dc:creator>
      <dc:date>2023-05-17T00:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876241#M346211</link>
      <description>Posters can edit their own posts for a short time, after which they need to ask for moderator help. This helps to keep the integrity of the question after others reply.</description>
      <pubDate>Wed, 17 May 2023 14:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876241#M346211</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-05-17T14:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file to SAS import issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876338#M346241</link>
      <description>Ok, thank you for the note &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;; that will be helpful for future posts.&lt;BR /&gt;</description>
      <pubDate>Wed, 17 May 2023 22:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-file-to-SAS-import-issues/m-p/876338#M346241</guid>
      <dc:creator>Wub_SAS</dc:creator>
      <dc:date>2023-05-17T22:18:49Z</dc:date>
    </item>
  </channel>
</rss>

