I am having a hard time reading external data from a .TXT file. I used to do that easily using other SAS versions.
The program is shown below:
filename YaraCASA '/folders/myfolders/YaraCASA.txt' lrecl=2000;
data YaraCASA;
infile YaraCASA missover;
input COLETA HORA TRATAM MACHO MOTTOT MOTPROG DAP DCL DSL VAP VCL VSL STR LIN WOB ALH BCF TRDSL TRVSL TRWOB LOGLIN;
PROC GLM;
CLASS COLETA TRATAM HORA MACHO;
MODEL MOTTOT = TRATAM MACHO(TRATAM) HORA COLETA COLETA*TRATAM HORA*TRATAM;
RANDOM MACHO(TRATAM) / TEST;
LSMEANS TRATAM HORA*TRATAM / STDERR PDIFF;
RUN;
The error message I get follows next:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 filename YaraCASA '/folders/myfolders/YaraCASA.txt' lrecl=2000;
57 data YaraCASA;
58 infile YaraCASA missover;
59 input COLETA HORA TRATAM MACHO MOTTOT MOTPROG DAP DCL DSL VAP VCL VSL STR LIN WOB ALH BCF TRDSL TRVSL TRWOB LOGLIN;
60
NOTE: The infile YARACASA is:
Filename=/folders/myfolders/YaraCASA.txt,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=10 de dezembro de 2015 14h24min40s,
File Size (bytes)=30467
NOTE: Invalid data for COLETA in line 1 1-102.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
Without the complete error message I am guessing that you have text data in a variable that should be numeric from the datastep code that you posted.
If the text appears to be a column heading you might just need to add firstobs=2 to the infile statement.
If the source of the data has changed the content then you may have to have a discussion about the field type with the provider.
I tried inserting the firstobs=2 in trhe infile statement. I did not help much. A more complete error message is below. Any help on that would be deeply appreciated.
NOTE: The infile YARACASA is:
Filename=/folders/myfolders/YaraCASA.txt,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
File Size (bytes)=30467
NOTE: Invalid data for COLETA in line 2 1-103.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
2 CHAR 1.0.1.82.56.73.36.99.21.50.43.42.15.94.45.00.90.91.33.38.0.73.0.36.0.49.2.56.33.24.0.13.0.18.0.02.-0
ZONE 3030303303323303323303323303323303323303323303323303323303233032330323303233033233032330323303233023
NUMR 19091982956E73936E99921E50943E42915E94945E00990E91933E3890E7390E3690E4992E56933E2490E1390E1890E029D0
101 .44 103
COLETA=. HORA=. TRATAM=. MACHO=. MOTTOT=. MOTPROG=. DAP=. DCL=. DSL=. VAP=. VCL=. VSL=. STR=. LIN=. WOB=. ALH=. BCF=. TRDSL=.
TRVSL=. TRWOB=. LOGLIN=. _ERROR_=1 _N_=1
NOTE: Invalid data for COLETA in line 3 1-104
Weel, I tried this one, but it did not work either,
Erro message below:
filename YaraCASA '/folders/myfolders/YaraCASA.txt' lrecl=2000;
data YaraCASA;
infile YaraCASA dlm='.' truncover;
input COLETA HORA TRATAM MACHO MOTTOT MOTPROG DAP DCL DSL VAP VCL VSL STR LIN WOB ALH BCF TRDSL TRVSL TRWOB LOGLIN;
NOTE: The infile YARACASA is:
Filename=/folders/myfolders/YaraCASA.txt,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
File Size (bytes)=30467
NOTE: Invalid data for COLETA in line 1 1-11.
NOTE: Invalid data for HORA in line 1 13-16.
NOTE: Invalid data for TRATAM in line 1 18-22.
NOTE: Invalid data for MACHO in line 1 24-28.
NOTE: Invalid data for MOTTOT in line 1 30-34.
NOTE: Invalid data for MOTPROG in line 1 36-40.
NOTE: Invalid data for DAP in line 1 42-46.
NOTE: Invalid data for DCL in line 1 48-52.
NOTE: Invalid data for DSL in line 1 54-57.
NOTE: Invalid data for VAP in line 1 59-62.
NOTE: Invalid data for VCL in line 1 64-67.
NOTE: Invalid data for VSL in line 1 69-72.
NOTE: Invalid data for STR in line 1 74-78.
NOTE: Invalid data for LIN in line 1 80-83.
NOTE: Invalid data for WOB in line 1 85-88.
NOTE: Invalid data for ALH in line 1 90-93.
NOTE: Invalid data for BCF in line 1 95-99.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1 CHAR 1.0.1.81.23.19.9.77.16.64.35.14.11.85.35.27.74.22.25.20.0.71.0.34.0.48.2.29.33.98.0.11.0.16.0.02.-0.
ZONE 3030303303323303233033233033233033233033233033233033233032330323303233032330332330323303233032330232
NUMR 19091981923E1999E77916E64935E14911E85935E27974E22925E2090E7190E3490E4892E29933E9890E1190E1690E029D0E
101 47 102
COLETA=. HORA=. TRATAM=. MACHO=. MOTTOT=. MOTPROG=. DAP=. DCL=. DSL=. VAP=. VCL=. VSL=. STR=. LIN=. WOB=. ALH=. BCF=. TRDSL=47
TRVSL=. TRWOB=. LOGLIN=. _ERROR_=1 _N_=1
As far as I can tell from the "ZONE" and "NUMR" lines shown in your log, this is a tab-delimited file. So, you should use dlm='09'x instead of dlm='.'.
(The dots replacing non-printable characters in the "CHAR" line can be misleading at times.)
Hi,
The dlm='09'x worked!!!
Thanks a lot.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.