Hi,
I need to read an external file with the following specific.
The first filed is a date in the format MM/DD/YYYY HH:MM:SS, then we have a character field of variable lenght and then we have a number. The number should have decimal digits and not.
The separator is ";"
Example
11/30/2011 0.30.50;XXX;100.45
12/01/2011 12.00.40;YYYY;98
I've tried with mmddyyyy, anydtdtm and some other stuffs like this but nothing is working. Also trying to read the number Im getting problem.
I'm sorry but I'm new with SAS.
Any suggestion will be very appreciate.
Thanks.
This code worked for me.
DATA one;
infile 'c:\temp\mydata.txt' dlm=';';
INFORMAT dt1 anydtdtm. txt1 $8. num1 best12.;
FORMAT Dt1 datetime21.;
INPUT dt1 txt1 num1;
RUN;
The data are also easy to bring in using Enterprise Guide.
Doc Muhlbaier
Duke
Hi Doc@Duke,
many thanks for your reply.
It's work but I forget to specify another option.
If the XXX or YYY are missing, I mean if I have a row like this,
11/30/2011 0.30.50;;100.45
it should be continue to work saving a missing value on the second variable of the dataset for that observation.
Right now it shift the values to left.
I've tried with the attribute missover but it does not work.
Do you have any idea?
Thanks again.
See "reading delimited data" in
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm
The DSD option addresses consecutive delimiters.
The option DSD was necessary.
It works perfectly now.
Many thanks.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.