BookmarkSubscribeRSS Feed
ldeepikach
Calcite | Level 5

How to write a SAS Dataset To a Text File without any delimiter using file statements

4 REPLIES 4
Reeza
Super User

Is this a fixed width file, where you expect every variable to have the same length in every observation?

Or will you need to pad the variable in certain cases?


SAS FAQ: How do I write out a fixed-format file in SAS?

Ksharp
Super User

Not sure if it was what you are looking for.

data _null_;
 set sashelp.class;
 file 'c:\temp\x.txt' ;
 put (_all_) ( +(-1) :);
run;

Xia Keshan

RamKumar
Fluorite | Level 6

Excellent!

what does ( +(-1) :); indicates? In similar way can we apply delimiters  instead of normal put statement like put "|" id "|" female "|" race "?  Also how to display the observation in line by line (rows) rather than outputting all the observations in single line?

Ksharp
Super User

"what does ( +(-1) :); indicates?"

It means we will backward a position to output. i.e. delimiter will not be appeared.

"In similar way can we apply delimiters  instead of normal put statement like put "|" id "|" female "|" race "?  "

Yes. you can.

data _null_;

set sashelp.class;

file 'c:\temp\x.txt' dlm='|';

put (_all_) (:);

run;

"Also how to display the observation in line by line (rows) rather than outputting all the observations in single line?"

Curious. Mine is in line by line , not  in a single line . Are you creating this file in UNIX and browse it in WINDOWS?

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1663 views
  • 0 likes
  • 4 in conversation