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
SAS Super FREQ
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]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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