Help using Base SAS procedures

Reading external file

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Reading external file

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:MMSmiley FrustratedS, 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.


Accepted Solutions
Solution
‎12-09-2011 11:15 AM
Contributor
Posts: 58

Reading external file

The option DSD was necessary.

It works perfectly now.

Many thanks.

View solution in original post


All Replies
Trusted Advisor
Posts: 2,115

Reading external file

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

Contributor
Posts: 58

Reading external file

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.

Trusted Advisor
Posts: 2,115

Reading external file

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.

Solution
‎12-09-2011 11:15 AM
Contributor
Posts: 58

Reading external file

The option DSD was necessary.

It works perfectly now.

Many thanks.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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