I've started moving doing more of my own coding vs using enterprise guide and I have a puzzling issue. I have the same input statement, that works just great with the input in a datalines, but when I try and use a and INFILE, sas complains about data format issues. I'm running SAS 9.2 on AIX. I am doing all my edits on the unix box so I doubt it's some sort of unix/dos formatting issue. I'm a little puzzled. If I read it all in as strings and convert it also seems to work fine, but that's more work when I have 500 or so fields.
This works fine:
OPTIONS DATESTYLE=MDY;
data &TEMP_DS;
format timeStamp dateampm22. ;
input tdate mmddyy11. hourStamp adjCount comma8.;
timeStamp=dhms(tdate,hourStamp,30,0);
keep timeStamp hourStamp adjCount;
label
timeStamp = "TimeStamp"
adjCount = "Adjucation Count"
;
datalines;
01/01/2010 3 321
01/01/2010 4 335
01/01/2010 5 376
01/01/2010 6 383
01/01/2010 7 385
;
But when this same data is in a file and try to use:
INFILE "/user_data/adjdata.txt"
MISSOVER
DSD
;
I get:
NOTE: Invalid data for hourStamp in line 1 12-19.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1 01/01/2010 3 321 19
timeStamp=. dateStamp=. tdate=18263 hourStamp=. adjCount=. _ERROR_=1 _N_=1
hi ,
use truncover and pad ...in the follwing step..??
INFILE "/user_data/adjdata.txt"
truncover
DSD;
input tdate mmddyy11. @13 hourStamp @16 adjCount comma8.;
That doesn't seem to help. I still get the same error.
NOTE: Invalid data for hourStamp in line 1 12-19.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1 01/01/2010 3 321 19
timeStamp=. dateStamp=. tdate=18263 hourStamp=. adjCount=. _ERROR_=1 _N_=1
What does "Invalid data" mean, is there any more detail somewhere?
hi,
when you are pasting the data from 'datalines ' in to txt file .....some wrong alligment for the 'tdate' and 'hourstamp'...is happening .. while importing it will give wrong...allingment...please check this
or
eg : please delete the first row of your data and check...
i have not observed any errors with following code ..
Note : i have adjusted the alligment of first row !!
data TEMP_DS;
infile "C:\Users\galax_allu\Desktop\adjdata.txt" truncover pad;
OPTIONS DATESTYLE=MDY;
format timeStamp dateampm22. ;
input tdate mmddyy11. hourStamp adjCount comma8.;
timeStamp=dhms(tdate,hourStamp,30,0);
keep timeStamp hourStamp adjCount;
label
timeStamp = "TimeStamp"
adjCount = "Adjucation Count"
;
run;
Regards
Allu
..
PAD is redundant if you are using TRUNCOVER.
thanks Tom..
Why are you using DSD option? That will make it attempt to read the lines as if the fields were separated with commas. So you read the first 11 columns because of the explicit informat length. So then it reads the rest of the line (columns 12 to 19 in this case) as one field and the embedded space makes it an invalid number.
Also do not use MISSOVER as that will set values to missing when only part of it is available on the same line. Use the TRUNCOVER option instead so when you attempt to read past the end of the line if keeps the values that are there.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: