<?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: Reading data from external file in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757640#M239177</link>
    <description>&lt;P&gt;Can you be sure there's always two lines for a single person, in immediate succession?&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 10:50:45 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-07-28T10:50:45Z</dc:date>
    <item>
      <title>Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757637#M239176</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have below requirement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a external file I have data like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sam,&lt;A href="mailto:sam11@abc.com" target="_blank"&gt;sam11@abc.com&lt;/A&gt;&amp;nbsp;,abc&amp;nbsp;&lt;/P&gt;
&lt;P&gt;22/09/1992,Math&lt;/P&gt;
&lt;P&gt;Ram,&lt;A href="mailto:sam11@abc.com" target="_blank"&gt;ram5@abc.com&lt;/A&gt;&amp;nbsp;,xyz&lt;/P&gt;
&lt;P&gt;22/09/1993, English&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to read data from this file and get output like&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sam,&lt;A href="mailto:sam11@abc.com" target="_blank"&gt;sam11@abc.com&lt;/A&gt;&amp;nbsp;,abc&amp;nbsp;22/09/1992,Math&lt;/P&gt;
&lt;P&gt;Ram,&lt;A href="mailto:sam11@abc.com" target="_blank"&gt;ram5@abc.com&lt;/A&gt;&amp;nbsp;,xyz22/09/1993, English&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know the how can i solve this.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 10:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757637#M239176</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-07-28T10:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757640#M239177</link>
      <description>&lt;P&gt;Can you be sure there's always two lines for a single person, in immediate succession?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 10:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757640#M239177</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-28T10:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757641#M239178</link>
      <description>Yes.&lt;BR /&gt;&lt;BR /&gt;Sam,sam11@abc.com ,abc &lt;BR /&gt;22/09/1992,Math&lt;BR /&gt;Ram,ram5@abc.com ,xyz&lt;BR /&gt;22/09/1993, English</description>
      <pubDate>Wed, 28 Jul 2021 11:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757641#M239178</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-07-28T11:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757646#M239181</link>
      <description>&lt;P&gt;Then you just need two INPUTs per data step iteration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile datalines dlm=",";
length
  name $10
  email $50
  whatever $3
  date 4
  course $15
;
format date ddmmyy10.;
input name email whatever;
input date:ddmmyy10. course;
datalines;
Sam,sam11@abc.com ,abc 
22/09/1992,Math
Ram,ram5@abc.com ,xyz
22/09/1993, English
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 11:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757646#M239181</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-28T11:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757680#M239192</link>
      <description>&lt;P&gt;Or one input-statement with the / (means: start reading next line)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile datalines dlm=",";
length
  name $10
  email $50
  whatever $3
  date 4
  course $15
;
format date ddmmyy10.;
input name email whatever / date:ddmmyy10. course;
datalines;
Sam,sam11@abc.com ,abc 
22/09/1992,Math
Ram,ram5@abc.com ,xyz
22/09/1993, English
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 13:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/757680#M239192</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-28T13:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/758601#M239558</link>
      <description>&lt;P&gt;You could even omit the slash because the default behavior of the INPUT statement is to read the remaining values, if any, from the next line (see&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#p1fdvsp2n4yna3n1ht0222w1okyl" target="_blank" rel="noopener"&gt;Reading Past the End of a Line&lt;/A&gt;) -- at the cost of an additional note in the log:&lt;/P&gt;
&lt;PRE&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/PRE&gt;</description>
      <pubDate>Sat, 31 Jul 2021 16:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/758601#M239558</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-31T16:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/758607#M239560</link>
      <description>&lt;P&gt;Let's put your example lines into a file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=old;
filename old temp;

parmcards4;
Sam,sam11@abc.com ,abc 
22/09/1992,Math
Ram,ram5@abc.com ,xyz
22/09/1993, English
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Do you want to generate a new text file without the extra line break?&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename new temp;
data _null_;
  infile old;
  file new;
  input ;
  put _infile_ ',' @;
  input;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Sam,sam11@abc.com ,abc,22/09/1992,Math
Ram,ram5@abc.com ,xyz,22/09/1993, English&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Or did you&amp;nbsp;want to read the file into a SAS dataset?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;We can just read it and SAS will automatically jump to the next line when it runs out of values on the first line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile old dsd ;
  input name :$20. email :$200. other :$20. date :ddmmyy. department :$20. ;
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 513px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62170i885A125D8FAD8BDD/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Or we could tell it when to move to a new line.&amp;nbsp; In that case you might want to add the TRUNCOVER option to prevent if from moving too soon.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile old dsd truncover ;
  input name :$20. email :$200. other :$20. / date :ddmmyy. department :$20. ;
  format date yymmdd10.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile old dsd truncover ;
  input #1 name :$20. email :$200. other :$20. #2 date :ddmmyy. department :$20. ;
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or even&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile old dsd truncover ;
  input name :$20. email :$200. other :$20.;
  input date :ddmmyy. department :$20. ;
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Jul 2021 19:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/758607#M239560</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-31T19:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from external file in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/758738#M239637</link>
      <description>This is awesome. &lt;BR /&gt;Thanks for explaining &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;My requirement was only to  generate a new text file without the extra line break but I got to know  many things. Thanks.</description>
      <pubDate>Mon, 02 Aug 2021 10:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-external-file-in-SAS/m-p/758738#M239637</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-08-02T10:37:45Z</dc:date>
    </item>
  </channel>
</rss>

