BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abdulla
Pyrite | Level 9

Can anyone help me with the following? 

 

proc export data=have

outfile="&output.want.dat"

dbms=DLM

replace;

run;

 

I have my libname created. But this one is not working

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your PROC EXPORT creates a text file with a .dat extension not a SAS7BDAT file. 

If you want a SAS7BDAT file you place it into that library and the file is created. If you want a text file you use a PROC EXPORT and ensure you have the path correct. 

 

"Export"/Save to a SAS7BDAT file to the myfolders folder. 

libname myFiles "/folders/myfolders/";

proc copy in=work  /*library of input files*/
                out=myFiles; /*library of output files*/
select WANT; *dataset to copy is called want;
run;

Export to a text file - Tab (09x) delimited, if you want a different delimiter change the delimiter statement. 

proc export data=sashelp.class
outfile = "/folders/myfolders/class.dat" dbms=dlm replace;
delimiter = '09'x;
run;

Make sure you code works before you add macro variables and then add the macro variables once it's working. 

 


@abdulla wrote:

Can anyone help me with the following? 

 

proc export data=have

outfile="&output.want.dat"

dbms=DLM

replace;

run;

 

I have my libname created. But this one is not working


 

View solution in original post

14 REPLIES 14
CurtisMackWSIPP
Lapis Lazuli | Level 10

In your example, have is already a sas7bdat file since it is in the work library.

If you want to copy it to a permanent  library you can use proc copy, or just another data step. 

libname dest "&output";
data dest.want;
  set have;
run;

The export procedure for creating non-SAS files.

 

abdulla
Pyrite | Level 9
This doesn't create sas7bdat file. It creates a file for as code, not for data.
CurtisMackWSIPP
Lapis Lazuli | Level 10

You asked to:

export dataset to a sas7bdat

SAS7BDAT is the extension for a SAS dataset.

What format do you want output, and where?

CurtisMackWSIPP
Lapis Lazuli | Level 10
%let output = C:\temp\;
data have;
  x = 1;
run;
proc export data=have
   outfile="&output.want.dat"
   dbms=DLM
   replace;
run;

 Is this what you are trying to do?

abdulla
Pyrite | Level 9
ERROR: Export unsuccessful. See SAS Log for details
CurtisMackWSIPP
Lapis Lazuli | Level 10
Does my last example work?
abdulla
Pyrite | Level 9
No, it doesn't. It gives the following:

ERROR: Export unsuccessful. See SAS Log for details
CurtisMackWSIPP
Lapis Lazuli | Level 10

Is there anything further up the log that gives more information?

Did you change the line:

 

%let output = C:\Temp\

 

To a location that exists and that you have write permission too?

abdulla
Pyrite | Level 9
I copied your data and just changed the path to see whether it works or not. It doesn't export file. Is it working for you?
CurtisMackWSIPP
Lapis Lazuli | Level 10

Yes, that code runs exactly like it is posted.

Are you making sure your path ends in a \ ?

abdulla
Pyrite | Level 9
Yes. I made sure that. I will close my all files and run the data again. I will let you know it it works or not
Reeza
Super User

If your code isn't working after this, post the exact code and log. 

 


@abdulla wrote:
Yes. I made sure that. I will close my all files and run the data again. I will let you know it it works or not

 

abdulla
Pyrite | Level 9
It didn't work. By the way, I got the solution. Thank you for your effort.
Reeza
Super User

Your PROC EXPORT creates a text file with a .dat extension not a SAS7BDAT file. 

If you want a SAS7BDAT file you place it into that library and the file is created. If you want a text file you use a PROC EXPORT and ensure you have the path correct. 

 

"Export"/Save to a SAS7BDAT file to the myfolders folder. 

libname myFiles "/folders/myfolders/";

proc copy in=work  /*library of input files*/
                out=myFiles; /*library of output files*/
select WANT; *dataset to copy is called want;
run;

Export to a text file - Tab (09x) delimited, if you want a different delimiter change the delimiter statement. 

proc export data=sashelp.class
outfile = "/folders/myfolders/class.dat" dbms=dlm replace;
delimiter = '09'x;
run;

Make sure you code works before you add macro variables and then add the macro variables once it's working. 

 


@abdulla wrote:

Can anyone help me with the following? 

 

proc export data=have

outfile="&output.want.dat"

dbms=DLM

replace;

run;

 

I have my libname created. But this one is not working


 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 14 replies
  • 50063 views
  • 2 likes
  • 3 in conversation