<?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: Infile way to import first 5 observations into sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874217#M345373</link>
    <description>&lt;P&gt;If you want to read only 5 observations from a text file that has a header row you need to read 6 lines from the file.&lt;/P&gt;
&lt;P&gt;So this code will read the first 10 variables from the first 5 observation of the CSV file.&amp;nbsp; It will make them all character with a maximum length of 200 bytes so you can take a look at what they might contain.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "/path/BLL_ISK.csv" dsd dlm=';' firstobs=2 obs=6 truncover;
  input (x1-x10) (:$200.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want to take a look at the first 6 lines (including the header line) so you can get a sense of what variables there are then just use the LIST statement to dump the lines to the SAS log.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "/path/BLL_ISK.csv" obs=6 ;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 05 May 2023 21:55:31 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-05-05T21:55:31Z</dc:date>
    <item>
      <title>Infile way to import first 5 observations into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874212#M345369</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Let's say that there is a very big csv file (150 million rows).&lt;/P&gt;
&lt;P&gt;I want to import only first 5 rows into sas data set.&lt;/P&gt;
&lt;P&gt;I know to do it via proc import&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options obs=5;
proc import
datafile="/path/BLL_ISK.csv"
out=want1
dbms=CSV
replace;
delimiter=';';
GETNAMES=YES;
run;
options obs=max;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't know how to do it via Infile way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May anyone show?&lt;/P&gt;
&lt;P&gt;Please note that I don't want to read all file and then a&lt;SPAN&gt;pply option of (obs=5) because it will take very long ru&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 20:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874212#M345369</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-05T20:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Infile way to import first 5 observations into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874213#M345370</link>
      <description>&lt;P&gt;If you put obs=X , x a number,&amp;nbsp; on the INFILE statement that is the number of records that will be read assuming you read one line as one record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OBS= option does different things depending on where you are using. You obviously know about the SYSTEM option.&lt;/P&gt;
&lt;P&gt;It is also a Dataset option:&lt;/P&gt;
&lt;PRE&gt;Proc print data=sashelp.class (obs=5);
run;&lt;/PRE&gt;
&lt;P&gt;Used this way with a data&amp;nbsp; set you are telling SAS to only use the first 5 observations in the procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 21:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874213#M345370</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-05T21:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Infile way to import first 5 observations into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874217#M345373</link>
      <description>&lt;P&gt;If you want to read only 5 observations from a text file that has a header row you need to read 6 lines from the file.&lt;/P&gt;
&lt;P&gt;So this code will read the first 10 variables from the first 5 observation of the CSV file.&amp;nbsp; It will make them all character with a maximum length of 200 bytes so you can take a look at what they might contain.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "/path/BLL_ISK.csv" dsd dlm=';' firstobs=2 obs=6 truncover;
  input (x1-x10) (:$200.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want to take a look at the first 6 lines (including the header line) so you can get a sense of what variables there are then just use the LIST statement to dump the lines to the SAS log.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "/path/BLL_ISK.csv" obs=6 ;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 May 2023 21:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-way-to-import-first-5-observations-into-sas/m-p/874217#M345373</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-05T21:55:31Z</dc:date>
    </item>
  </channel>
</rss>

