BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
garag
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
garag
Calcite | Level 5

The option DSD was necessary.

It works perfectly now.

Many thanks.

View solution in original post

4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12

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

garag
Calcite | Level 5

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.

Doc_Duke
Rhodochrosite | Level 12

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.

garag
Calcite | Level 5

The option DSD was necessary.

It works perfectly now.

Many thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 735 views
  • 6 likes
  • 2 in conversation