BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi!

Is there any way that I can convert a SAS data set to a flat text file (with no delimiters)?

Thank you.
5 REPLIES 5
Cynthia_sas
Diamond | Level 26
Yes, there is. Depending on your expertise with SAS, you can export the data using the Export Wizard and select a space ( ) character as the delimiter or you can write a DATA _NULL_ program and use PUT statements to create your flat file. There are many examples in the documentation of creating flat files using SAS.

cynthia
Ksharp
Super User
It looks like Patrick give a solution in the preceding posts.
Such as :
[pre]
data _null_;
set sashelp.class;
file 'd:\download\class.txt';
put name= +1 / sex= +1 / age= +1 /;
run;
[/pre]

It is what you want.
Ksharp
Super User
Hi!
You can search what you are looking for in sas forum.
Patrick
Opal | Level 21
Hi
A data step version writing the values of all variable of a data set to an external file without delimiters.
HTH
Patrick

data test;
format b z5.;
a=' abc ';
b=1;
c=' Just a test';
d=1234456778;
e=' The end';
run;

proc sql noprint;
select strip(name) into :PutVarList separated by ' +(-1) '
from dictionary.columns
where libname='WORK' and memname='TEST'
;
quit;

%put PutVarList= &PutVarList;

data _null_;
set test;
file print;
put &PutVarList;
run;
data_null__
Jade | Level 19
Seems to me that creating a file with no delimiter, space or otherwise, can only be useful if the length of each field is fixed. You cannot use LIST PUT for that you
would need to use column or formatted put. For example.

[pre]
put a z5. b f8. c$20. d f12. e $16.;
[/pre]

Patrick,

You can make your program much shorter if you take avantage of features of the PUT statement.

[pre]
data _null_;
set test;
file print;
put (_all_) (+(-1));
run;
[/pre]

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 4989 views
  • 0 likes
  • 5 in conversation