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-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!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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