<?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 convert text file to SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140488#M261509</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to convert many text a file to sas dataset without using DDE. My file is like the following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Label define&amp;nbsp; age ///&lt;/P&gt;&lt;P&gt;1 "10 to 20"///&lt;/P&gt;&lt;P&gt;2 "20 to 30 "///&lt;/P&gt;&lt;P&gt;3 "30 to 40 "///&lt;/P&gt;&lt;P&gt;5 "40 to 50"///&lt;/P&gt;&lt;P&gt;6 "50 to 60"///&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to read the file and use fread, fget functions to read each line but i couldnot figureout how to create the dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;%do&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;%while&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;(fread(&amp;amp;fid1)) = &lt;SPAN style="color: #008080;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: #0000ff;"&gt;%let&lt;/SPAN&gt; rc=&lt;SPAN style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;(fread(&amp;amp;fid1));&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: #0000ff;"&gt;%let&lt;/SPAN&gt; rc=&lt;SPAN style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;(fget(&amp;amp;fid1,C,200));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Jul 2014 14:36:17 GMT</pubDate>
    <dc:creator>Maya_QC</dc:creator>
    <dc:date>2014-07-29T14:36:17Z</dc:date>
    <item>
      <title>convert text file to SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140488#M261509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to convert many text a file to sas dataset without using DDE. My file is like the following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Label define&amp;nbsp; age ///&lt;/P&gt;&lt;P&gt;1 "10 to 20"///&lt;/P&gt;&lt;P&gt;2 "20 to 30 "///&lt;/P&gt;&lt;P&gt;3 "30 to 40 "///&lt;/P&gt;&lt;P&gt;5 "40 to 50"///&lt;/P&gt;&lt;P&gt;6 "50 to 60"///&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to read the file and use fread, fget functions to read each line but i couldnot figureout how to create the dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;%do&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;%while&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;(fread(&amp;amp;fid1)) = &lt;SPAN style="color: #008080;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: #0000ff;"&gt;%let&lt;/SPAN&gt; rc=&lt;SPAN style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;(fread(&amp;amp;fid1));&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: #0000ff;"&gt;%let&lt;/SPAN&gt; rc=&lt;SPAN style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;(fget(&amp;amp;fid1,C,200));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 14:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140488#M261509</guid>
      <dc:creator>Maya_QC</dc:creator>
      <dc:date>2014-07-29T14:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: convert text file to SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140489#M261510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure what your structure is there, what do the /// reference?&amp;nbsp; What are the variables?&lt;/P&gt;&lt;P&gt;At a guess:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib id format=best. age format=$20. otherbit format=$20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "...\your_file_here.txt" dlm=" " dsd missover;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id age $ otherbit $;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 14:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140489#M261510</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-29T14:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: convert text file to SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140490#M261511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Possible minor change to RW9's code:&lt;/P&gt;&lt;P&gt;dlm " /" and don't bother reading in the otherbit variable unless there is some purpose to that /// other than saying end of line or data section.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 16:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-text-file-to-SAS-dataset/m-p/140490#M261511</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-07-30T16:19:15Z</dc:date>
    </item>
  </channel>
</rss>

