<?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: Importing .csv file to SAS studio in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700231#M214277</link>
    <description>&lt;P&gt;Likely should add: Guessingrows=max; to examine more of the data.&lt;/P&gt;
&lt;P&gt;Sparsely occupied variables that aren't populated in the first few rows of data may not get read properly as the proc only&amp;nbsp; uses about 20 rows by default to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't help there may be issues with content that would require more information to address.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Nov 2020 15:56:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-19T15:56:06Z</dc:date>
    <item>
      <title>Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700219#M214276</link>
      <description>&lt;P&gt;My data set has 30,000 subjects and 2,400 variables.&lt;/P&gt;&lt;P&gt;When I read the .csv file, it creates the same 2400 columns but some variables are not there. I tried both &lt;U&gt;proc import&lt;/U&gt; and &lt;U&gt;point-and-click in SAS-studio&lt;/U&gt;, both data sets in SAS have the correct number of rows and columns&amp;nbsp;(when checking the dimension) but both are missing some of the variables (the number of missing variables is more when I used&amp;nbsp;point-and-click)&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile='\\X\SASdata\dataset.csv'&lt;BR /&gt;out=dataset1&lt;BR /&gt;dbms=csv&lt;/P&gt;&lt;P&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is much appreciated. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 15:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700219#M214276</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2020-11-19T15:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700231#M214277</link>
      <description>&lt;P&gt;Likely should add: Guessingrows=max; to examine more of the data.&lt;/P&gt;
&lt;P&gt;Sparsely occupied variables that aren't populated in the first few rows of data may not get read properly as the proc only&amp;nbsp; uses about 20 rows by default to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't help there may be issues with content that would require more information to address.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 15:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700231#M214277</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-19T15:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700234#M214278</link>
      <description>&lt;P&gt;With 2400 columns (who comes up with such a bad table design?) it may well be that PROC IMPORT has troubles processing the header line.&lt;/P&gt;
&lt;P&gt;Maybe you find a way to create the data step programmatically from the file documentation.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 15:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700234#M214278</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-19T15:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700238#M214280</link>
      <description>&lt;P&gt;Proc Import has trouble when the header row is too long for it. If the average header value is 13 character long for 2,400 variables then the header row will be more than 32K bytes long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try running this simple step to see what the beginning of the text file looks like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile '\\X\SASdata\dataset.csv' obs=3;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Nov 2020 16:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700238#M214280</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-19T16:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700239#M214281</link>
      <description>&lt;P&gt;Thank you, KurBremser&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not need all the columns for my analyses. So, you think if I remove the columns from the .csv file, it may solve my problem?&lt;/P&gt;&lt;P&gt;Also, if a large data really has so many variables, what is your suggestion to make a better design for data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 16:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700239#M214281</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2020-11-19T16:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700243#M214283</link>
      <description>Thank you, ballardw! I added your suggestion to my code, but I think it is taking very long to run the Guessingrows=max for my large data set. may I add 50 instead of max?</description>
      <pubDate>Thu, 19 Nov 2020 16:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700243#M214283</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2020-11-19T16:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700247#M214284</link>
      <description>Thank you, Tom! I think that is the case for my data. The header values are long, on average even more than 13 characters.</description>
      <pubDate>Thu, 19 Nov 2020 16:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700247#M214284</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2020-11-19T16:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700253#M214287</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you, ballardw! I added your suggestion to my code, but I think it is taking very long to run the Guessingrows=max for my large data set. may I add 50 instead of max?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is a performance penalty.&lt;/P&gt;
&lt;P&gt;If you need performance then write a data step and do not rely on a guessing procedure.&lt;/P&gt;
&lt;P&gt;At a minimum with 30,000 records I would use a minimum of 1000 rows if forced but I would actually use the guessingrow=max and wait.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or write a data step. If you have a document describing the file you might be able to do that easily. If not the question might be why there are 2400 variables. If someone is doing a typical-trained-on-spreasheets approach of having a separate column for each time period/occasion/person instead of a variable holding time period/occasion/person identification then likely you will want to fix that later (or go back to the source and get a much nicer to work with file structure).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 16:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700253#M214287</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-19T16:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700271#M214292</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you, KurBremser&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not need all the columns for my analyses. So, you think if I remove the columns from the .csv file, it may solve my problem?&lt;/P&gt;
&lt;P&gt;Also, if a large data really has so many variables, what is your suggestion to make a better design for data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No need to remove the columns from the CSV file (that would just introduce a risk of corrupting the data.)&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can just not keep the variables you don't need.&amp;nbsp; You do need to read each variable up to the last variable on the line you want to keep.&amp;nbsp; But you could just read them all into a dummy variable that you drop before writing the dataset.&lt;/P&gt;
&lt;P&gt;Much easier to just write your own DATA step than depend on PROC IMPORT guessing what to do with the file.&lt;/P&gt;
&lt;P&gt;Here is an example to read two character fields and three numeric fields, one of which is a date, from a file with at least 20 fields per line.&amp;nbsp; So it skips the 2 and 3 fields (reads them into the DUMMY variable) and also the 13 fields before the date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.csv' dsd truncover firstobs=2 ;
  length id $10 age 8 gender $6 weight date 8;
  length dummy $1 ;
  informat date date.;
  format date date9.;
  input id 2*dummy age gender weight 13*dummy  date;
  drop dummy;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Nov 2020 17:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700271#M214292</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-19T17:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700284#M214297</link>
      <description>Thank you for reviewing my other thoughts and for your example code!</description>
      <pubDate>Thu, 19 Nov 2020 17:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700284#M214297</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2020-11-19T17:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Importing .csv file to SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700988#M214604</link>
      <description>&lt;P&gt;Finally, I could not import the .csv file but&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;LIBNAME mylibname XLSX '\\C:\direction\filemname.xlsx';&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;worked very well with the correct rows and columns. The hint is that in the data step, I need to specify the Excel sheet that contains the data I want to work on (for me, it was sheet1)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data mydata;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set mylibname.sheet1;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run; &amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another point was that I kept the data the same that was read from the .xlsx file. When I converted the file to SAS data, it changed the type of the variables and I did not want that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, everyone!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 18:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-to-SAS-studio/m-p/700988#M214604</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2020-11-23T18:00:45Z</dc:date>
    </item>
  </channel>
</rss>

