I am trying to write a SAS program to read the text from a SAS program file.
Little more detailed explaination. Suppose I have a SAS program called myProg.sas
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
C:\MyOutputFolder.
To begin with,I wrote a small SAS program to read the SAS program text into a data set. My program looks like
data myData;
INFILE 'C:\DAG\SAS\Farmers\state_extract_forDAG.sas';
INPUT progText;
run;
I am getting error saying invalid data for progText. The log file errors are
------------------------------------------------------------------------------------------
NOTE: Invalid data for progText in line 2 1-4.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
2 data employee; 51
progText=. _ERROR_=1 _N_=1
NOTE: Invalid data for progText in line 3 3-7.
3 input lastname $ 1-10 fname $ 12-21 ssn 23-31 status $ 33-38; 65
progText=. _ERROR_=1 _N_=2
NOTE: Invalid data for progText in line 4 1-11.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
4 CHAR .datalines; 64
ZONE 0667666667322222222222222222222222222222222222222222222222222222
NUMR 94141C9E53B00000000000000000000000000000000000000000000000000000
progText=. _ERROR_=1 _N_=3
NOTE: Invalid data for progText in line 5 1-5.
5 Green Samual 888888888 Hourly 63
progText=. _ERROR_=1 _N_=4
NOTE: Invalid data for progText in line 6 1-7.
6 Brennon Carol 123456789 Salary 63
progText=. _ERROR_=1 _N_=5
NOTE: Invalid data for progText in line 7 1-4.
7 Wang Robert 999999999 Salary 63
progText=. _ERROR_=1 _N_=6
NOTE: Invalid data for progText in line 8 1-8.
8 Randolph Virginia 987654321 Salary 39
progText=. _ERROR_=1 _N_=7
NOTE: Invalid data for progText in line 9 1-1.
9 ; 1
progText=. _ERROR_=1 _N_=8
NOTE: Invalid data for progText in line 11 1-4.
11 data distance; 14
progText=. _ERROR_=1 _N_=9
NOTE: Invalid data for progText in line 12 1-5.
12 miles = 26.22; 14
progText=. _ERROR_=1 _N_=10
NOTE: Invalid data for progText in line 13 1-10.
13 kilometers = 1.61*miles; 24
progText=. _ERROR_=1 _N_=11
NOTE: Invalid data for progText in line 15 1-4.
15 proc print data = employee; 27
progText=. _ERROR_=1 _N_=12
NOTE: Invalid data for progText in line 17 1-4.
17 run; 4
progText=. _ERROR_=1 _N_=13
NOTE: 17 records were read from the infile 'C:\DAG\SAS\Farmers\Unit_Test_sample1.sas'.
The minimum record length was 0.
The maximum record length was 65.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.MYDATA has 13 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
------------------------------------------------------------------------------------------------
I am getting character '.' in all observation of MYDATA dataset
The .sas program file I'm trying to read is given below
------------------------------------------------------------------------------------------------
data employee;
input lastname $ 1-10 fname $ 12-21 ssn 23-31 status $ 33-38;
datalines;
Green Samual 888888888 Hourly
Brennon Carol 123456789 Salary
Wang Robert 999999999 Salary
Randolph Virginia 987654321 Salary
;
data distance;
miles = 26.22;
kilometers = 1.61*miles;
proc print data = employee;
run;
---------------------------------------------------------------------------------------------
Appreciate any help.
Thanks,
Neel