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

I tried to extract or read .dat file in SAS Studio using SAS code but data is not coming in proper format,

Below is the code i have used to read .dat files.

* Create a SAS data set named toads;

* Read the data file ToadJump.dat using list input;

DATA toads;

  INFILE 'c:\MyRawData\ToadJump.dat';

  INPUT ToadName $ Weight Jump1 Jump2 Jump3;

RUN;

* Print the data to make sure the file was read correctly;

PROC PRINT DATA = toads;

  TITLE 'SAS Data Set Toads';

RUN;

 

But this doesn't seems to be perfect, can anyone help me with the solution?

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
ahuja
Fluorite | Level 6

Hi, i got the answer to it but still thanks to all of you to reply on this.

View solution in original post

8 REPLIES 8
data_null__
Jade | Level 19

The answer is in ToadJump.dat but we cannot see ToadJump.dat from way over here.

ahuja
Fluorite | Level 6

ToadJump.dat is a data set, and i want to read the data available in ToadJump.dat data set through SAS, so the result should display on SAS.

But it's not displaying proper result, may be i am missing something in SAS code. Can you help me with the proper SAS code ?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

When you say ToadJump is a dataset, what application created that dataset.  The file extension .dat doesn't actually mean anything, it just stands for data.  This would be text data, delimited data e.g. csv, Oracle dump file, XML etc. 

For instance, what happens if you right click -> open with -> Notepad

on the file?   Does it show nice text data, if so then write a datastep import program.

If it shows weird characters and such like, then it is a binary file, these are generally proprietary for instance old Excel files were proprietary format and then you need the application which created it, or some in between software.

So where does the data come from?

ahuja
Fluorite | Level 6

This is text data

Reeza
Super User

How is it not perfect?

What does your data look like?

Without knowing what the 'imperfections' are we can't help.

ahuja
Fluorite | Level 6

After executing i get this data, i have attached image of data please find.Data Image.png

ahuja
Fluorite | Level 6

Hi, i got the answer to it but still thanks to all of you to reply on this.

Tom
Super User Tom
Super User

Looks like you could read the data, but perhaps it is not the types of numbers you expected?

You can just have the data step dump a few records of the source file to the log to see what it looks like.

DATA toads;

  INFILE 'c:\MyRawData\ToadJump.dat';

  INPUT ToadName $ Weight Jump1 Jump2 Jump3;

  if _n_ <= 10 then list ;

RUN;

SAS Innovate 2025: Register Now

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!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 55848 views
  • 0 likes
  • 5 in conversation