BookmarkSubscribeRSS Feed
jflo36
Calcite | Level 5

Hi,

how can I import a dat file into sas and create a text file output? I am new to sas. Thanks!

The dat file contain numeric values.

3 REPLIES 3
JoshB
Quartz | Level 8

.dat files are not really unique as far as SAS is concerned but your data structure will determine how easy it is to read in through a data step. Here are some resources with examples of importing .dat files.

 

As for exporting, you will have to decide what kind of delimiter you want for the file. For example, if you want to just have space delimited output, you can write the file with

 


data _null_ ;
    set have ; 
    FILE  'C:\want.txt' ; 
    PUT v1 v2 v3 ; 
run ;

You can specify the DLM option on the file statement for other delimiters on the output file.

 

As a side note, are you doing something else to the data? I.e., some kind of processing before writing it out? I would imagine so, but if you're purely wanting to turn a .dat file into a .txt file, you can just change the extension.

jflo36
Calcite | Level 5

Thanks very much JoshB!

Patrick
Opal | Level 21

Unlike something like ".xlsx" the suffix ".dat" doesn't really tell you which application created the file and in what format the data is stored in this file.

 

Sometimes ".dat" files are simply text files. Can you open it with a text editor and then see the data directly? Or do you know which application created this ".dat" file?

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 10113 views
  • 1 like
  • 3 in conversation