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?
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
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?
"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?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.