Help using Base SAS procedures

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

Reply
N/A
Posts: 1

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

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

Super User
Posts: 17,899

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

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?

Super User
Posts: 9,687

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

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

Regular Contributor
Posts: 168

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

Excellent!

what does ( +(-1) Smiley Happy; 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?

Super User
Posts: 9,687

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

"what does ( +(-1) Smiley Happy; 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_) (Smiley Happy;

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?

Ask a Question
Discussion stats
  • 4 replies
  • 227 views
  • 0 likes
  • 4 in conversation