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

Hi, 

 

I am trying to read a .dat file into SAS. Have done this before using the DATA step, but for some reason, it am unable to read this particular file. Opened it with a text file, and the data looks like a tab-delimited, so tried using PROC IMPORT. That didn't work either.  Attaching a screenshot of the data file.

 

Data screen shot:

Screenshot (87).png

 

DATA step code snippet:

data tv.alco;
infile  "/folders/myfolders/Trial/alcohol.dat" firstobs= 22;
input   Region $	Alcohol	Tobacco ;
run;

PROC IMPORT snippet:

proc import datafile="/folders/myfolders/Trial/alcohol.dat"
out = tv.alco dbms=dlm replace ;
delimiter= '09'x ;startrow=22;
run;

Any help is appreciated 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
What does the log show?
Second of all, in NotePad++ you can show invisible characters, can you show a screenshot with that turned on?

data tv.alco;
infile "/folders/myfolders/Trial/alcohol.dat" firstobs= 22 dlm='09'x dsd;
input Region $ Alcohol Tobacco ;
run;

Does the above work?

View solution in original post

2 REPLIES 2
Reeza
Super User
What does the log show?
Second of all, in NotePad++ you can show invisible characters, can you show a screenshot with that turned on?

data tv.alco;
infile "/folders/myfolders/Trial/alcohol.dat" firstobs= 22 dlm='09'x dsd;
input Region $ Alcohol Tobacco ;
run;

Does the above work?
tejasvutu
Calcite | Level 5

Thanks! That worked. Also got to learn about the DSD option. 

 

The log in case of the DATA step is below. Basically a bunch of invalid reads from the file.

snip2.PNG

 

 The Notepad++ screenshot with all the hidden characters:

snip.PNG

 

Thanks for your help! 🙂

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 7421 views
  • 1 like
  • 2 in conversation