<?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: read text from a .sas file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63337#M17997</link>
    <description>The error log shows progText as numeric.  Try assigning is as a long string before the INPUT, or format the INPUT.</description>
    <pubDate>Tue, 11 Aug 2009 19:47:05 GMT</pubDate>
    <dc:creator>Flip</dc:creator>
    <dc:date>2009-08-11T19:47:05Z</dc:date>
    <item>
      <title>read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63336#M17996</link>
      <description>I am trying to write a SAS program to read the text from a SAS program file. &lt;BR /&gt;
&lt;BR /&gt;
Little more detailed explaination. Suppose I have a SAS program called myProg.sas&lt;BR /&gt;
at location C:\MyFolder1\Myfolder2. I want to write a SAS program that will read the text from myProg.sas and then write it back to a text file to a destination location say&lt;BR /&gt;
C:\MyOutputFolder.&lt;BR /&gt;
&lt;BR /&gt;
To begin with,I wrote a small SAS program to read the SAS program text into a data set. My program looks like&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data myData;&lt;BR /&gt;
&lt;BR /&gt;
INFILE 'C:\DAG\SAS\Farmers\state_extract_forDAG.sas';&lt;BR /&gt;
&lt;BR /&gt;
INPUT progText;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I am getting error saying invalid data for progText. The log file errors are &lt;BR /&gt;
&lt;BR /&gt;
------------------------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Invalid data for progText in line 2 1-4.&lt;BR /&gt;
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;
2         data employee;                                      51&lt;BR /&gt;
progText=. _ERROR_=1 _N_=1&lt;BR /&gt;
NOTE: Invalid data for progText in line 3 3-7.&lt;BR /&gt;
3           input lastname $ 1-10 fname $ 12-21 ssn 23-31 status $ 33-38;   65&lt;BR /&gt;
progText=. _ERROR_=1 _N_=2&lt;BR /&gt;
NOTE: Invalid data for progText in line 4 1-11.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;
&lt;BR /&gt;
4   CHAR  .datalines;                                                      64&lt;BR /&gt;
    ZONE  0667666667322222222222222222222222222222222222222222222222222222&lt;BR /&gt;
    NUMR  94141C9E53B00000000000000000000000000000000000000000000000000000&lt;BR /&gt;
progText=. _ERROR_=1 _N_=3&lt;BR /&gt;
NOTE: Invalid data for progText in line 5 1-5.&lt;BR /&gt;
5         Green      Samual     888888888 Hourly                          63&lt;BR /&gt;
progText=. _ERROR_=1 _N_=4&lt;BR /&gt;
NOTE: Invalid data for progText in line 6 1-7.&lt;BR /&gt;
6         Brennon    Carol      123456789 Salary                          63&lt;BR /&gt;
progText=. _ERROR_=1 _N_=5&lt;BR /&gt;
NOTE: Invalid data for progText in line 7 1-4.&lt;BR /&gt;
7         Wang       Robert     999999999 Salary                          63&lt;BR /&gt;
progText=. _ERROR_=1 _N_=6&lt;BR /&gt;
NOTE: Invalid data for progText in line 8 1-8.&lt;BR /&gt;
8         Randolph   Virginia   987654321 Salary  39&lt;BR /&gt;
progText=. _ERROR_=1 _N_=7&lt;BR /&gt;
NOTE: Invalid data for progText in line 9 1-1.&lt;BR /&gt;
9         ; 1&lt;BR /&gt;
progText=. _ERROR_=1 _N_=8&lt;BR /&gt;
NOTE: Invalid data for progText in line 11 1-4.&lt;BR /&gt;
11        data distance; 14&lt;BR /&gt;
progText=. _ERROR_=1 _N_=9&lt;BR /&gt;
NOTE: Invalid data for progText in line 12 1-5.&lt;BR /&gt;
12        miles = 26.22; 14&lt;BR /&gt;
progText=. _ERROR_=1 _N_=10&lt;BR /&gt;
NOTE: Invalid data for progText in line 13 1-10.&lt;BR /&gt;
13        kilometers = 1.61*miles; 24&lt;BR /&gt;
progText=. _ERROR_=1 _N_=11&lt;BR /&gt;
NOTE: Invalid data for progText in line 15 1-4.&lt;BR /&gt;
15        proc print data = employee; 27&lt;BR /&gt;
progText=. _ERROR_=1 _N_=12&lt;BR /&gt;
NOTE: Invalid data for progText in line 17 1-4.&lt;BR /&gt;
17        run; 4&lt;BR /&gt;
progText=. _ERROR_=1 _N_=13&lt;BR /&gt;
NOTE: 17 records were read from the infile 'C:\DAG\SAS\Farmers\Unit_Test_sample1.sas'.&lt;BR /&gt;
      The minimum record length was 0.&lt;BR /&gt;
      The maximum record length was 65.&lt;BR /&gt;
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;BR /&gt;
NOTE: The data set WORK.MYDATA has 13 observations and 1 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
------------------------------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
I am getting character '.' in all observation of MYDATA dataset&lt;BR /&gt;
&lt;BR /&gt;
The .sas program file I'm trying to read is given below&lt;BR /&gt;
&lt;BR /&gt;
------------------------------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
data employee;                                     &lt;BR /&gt;
  input lastname $ 1-10 fname $ 12-21 ssn 23-31 status $ 33-38;  &lt;BR /&gt;
	datalines;                                                     &lt;BR /&gt;
Green      Samual     888888888 Hourly                         &lt;BR /&gt;
Brennon    Carol      123456789 Salary                         &lt;BR /&gt;
Wang       Robert     999999999 Salary                         &lt;BR /&gt;
Randolph   Virginia   987654321 Salary &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data distance;&lt;BR /&gt;
miles = 26.22;&lt;BR /&gt;
kilometers = 1.61*miles;&lt;BR /&gt;
&lt;BR /&gt;
proc print data = employee;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
---------------------------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Appreciate any help.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Neel</description>
      <pubDate>Tue, 11 Aug 2009 19:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63336#M17996</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T19:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63337#M17997</link>
      <description>The error log shows progText as numeric.  Try assigning is as a long string before the INPUT, or format the INPUT.</description>
      <pubDate>Tue, 11 Aug 2009 19:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63337#M17997</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-08-11T19:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63338#M17998</link>
      <description>Thank You.&lt;BR /&gt;
&lt;BR /&gt;
I kind of got it working with&lt;BR /&gt;
------------------------------------------------------------------------------------&lt;BR /&gt;
data myData;&lt;BR /&gt;
&lt;BR /&gt;
INFILE 'C:\DAG\SAS\Farmers\Unit_Test_sample1.sas' DLM = ';';&lt;BR /&gt;
&lt;BR /&gt;
LENGTH progText $ 200 ;&lt;BR /&gt;
INPUT progText;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
--------------------------------------------------------------------------------------&lt;BR /&gt;
I get every line of SAS program as one observation in the dataset&lt;BR /&gt;
&lt;BR /&gt;
I want to write each of these lines into a text file at a sepcific location say&lt;BR /&gt;
C:\DAG\MyFolder\myProg.txt&lt;BR /&gt;
&lt;BR /&gt;
I was thinking I can use ODS. I couldn't locate how to specify a text file for ODS.&lt;BR /&gt;
(I found abt csv,html &amp;amp; others though)&lt;BR /&gt;
&lt;BR /&gt;
Any help?&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Neelam</description>
      <pubDate>Tue, 11 Aug 2009 21:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63338#M17998</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T21:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63339#M17999</link>
      <description>I was able to find the option for outputting to a text file&lt;BR /&gt;
&lt;BR /&gt;
ODS listing file='someFile.txt'</description>
      <pubDate>Tue, 11 Aug 2009 21:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63339#M17999</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T21:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63340#M18000</link>
      <description>Anyone knows how to get rid of line numbers in the output file.&lt;BR /&gt;
&lt;BR /&gt;
I am getting the program text output to a .txt file. But I get line numbers which I don't want.&lt;BR /&gt;
&lt;BR /&gt;
Any Help?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Neel</description>
      <pubDate>Wed, 02 Sep 2009 23:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63340#M18000</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-02T23:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63341#M18001</link>
      <description>Hi Neel,&lt;BR /&gt;
&lt;BR /&gt;
you used proc print to create the listing if i got it right. just add the noobs option in your proc print statement.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Milton</description>
      <pubDate>Wed, 02 Sep 2009 23:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63341#M18001</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2009-09-02T23:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63342#M18002</link>
      <description>Thanks Milton!&lt;BR /&gt;
&lt;BR /&gt;
that helped..&lt;BR /&gt;
&lt;BR /&gt;
Any way to avoid the following standard SAS system line in the output?&lt;BR /&gt;
&lt;BR /&gt;
  The SAS System                      08:55 Thursday, September 3, 2009   4&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Neelam</description>
      <pubDate>Thu, 03 Sep 2009 16:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63342#M18002</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-03T16:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: read text from a .sas file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63343#M18003</link>
      <description>You can override the SAS-system default using:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS NODATE NONUMBER;&lt;BR /&gt;
TITLE; &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 03 Sep 2009 19:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/read-text-from-a-sas-file/m-p/63343#M18003</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-03T19:19:25Z</dc:date>
    </item>
  </channel>
</rss>

