BookmarkSubscribeRSS Feed
Kayla_Tan222
Calcite | Level 5


Hi, would like to ask how to export my result in sas7bdat format,

I run the code with dbms=sas7bdat but is does not work. isit anything wrong with my code?

 

 

 

proc export data = 201812

outfile = 'D:File\201812'

dbms = sas7bdat;

run;

15 REPLIES 15
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Kayla_Tan222 

 

sas7bdat is the filetype for SAS tables. So you cannot export to a sas7bdat-file, you already have it if you have a SAS table created in a data step or SAS procedure.

 

 

Kayla_Tan222
Calcite | Level 5

can't I export the table in other SAS format? is there any way for me to do this?

 

I don't want it to be excel file,txt file,dbf file or any other file type

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Kayla_Tan222 

 

I don't understand what you are trying to achieve. If you have a SAS Ddata set, it exists as a physical file with extension sas7bdat, and you can treat that file like all other files on your system, copy it in windows explorer, send it as an attachment in a mail......

 

There are special circumstances like transferring SAS files to/from very old SAS versions, where it is necessary to make a portable SAS file with proc CPORT and import it in the other version with proc cimport, but in most cases that wouldn't be necessary.

 

It would help a lot if you wrote something about the purpose, why you want to export it.

Kayla_Tan222
Calcite | Level 5

Hi ErikLund,

 

I want to save it as intermediary.

ErikLund_Jensen
Rhodochrosite | Level 12

I see.

 

You need a permanent SAS library, where the files are not deleted when the session ends. If you specify a single-level table name mytable, the file is created in the work library, but if you specify a 2-level table name mylib.mytable, the file is created in the permanent library mylib.

 

Depending on your setup, you might have such a library with libref SASUSER or EGTASK, otherwise you will have to define a libname and assign it to an existing folder, that is accssible from the SAS process. I cannot go into more details without knowing your setup.Are you working in SAS EG with a remote workspace server, or ??

Kayla_Tan222
Calcite | Level 5

Ya, it is SAS GE with a remote workspace server

ErikLund_Jensen
Rhodochrosite | Level 12

A good practice for EG application server setup is to include a permanent library for each user, so I would expect you to have something like this permanent library called EGTASK:

 

 

eg.gif

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Naming conventions might be different, so it would be a good idea to call the SAS administrator and ask what library to use.

 

Then - when you create a task - specify the output location:

 

 

Enterprise Guide.gif

Kayla_Tan222
Calcite | Level 5

Hi,

 

instead of saving it in the server, is there a way to let me to save it at another location?

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Kayla_Tan222 

 

I assume that you want the data set saved in a place, where you can read it again from EG. The sas data set is saved from the server session, but it can be any path anywhere, as long as it can be seen from the server. In theory - and given the permission to use UNC paths - it could be on your PC, but a file server would be a better choice. 

 

But if you have a usable path on the server, I think you could use that. I guess from your answer to @Kurt_Bremser, that the problem occurs when writing the file. but you are a little bit sparse in your informations. Please run the following code an then post the full code you submitted and the full log written. 

 

libname mylib "\\kaiwksgh415thw5\Data\POLA\2018\201812";

data mylib.POLA_clm_mth_201812;
	do i = 1 to 10;
		output;
	end;
run;

libname mylib clear;

libname mylib "\\kaiwksgh415thw5\Data\POLA\2018\201812";

data work.test; set mylib.POLA_clm_mth_201812;
run;
Kayla_Tan222
Calcite | Level 5

Hi all,

 

I am facing a problem when I tried to open the SASdataset that I have saved in my local computer file.

My SAS EG is with a remote workspace server.

 

when I tried to open, it pop out a window with these words:

""The open data operation failed. The following error occurred. An unknown error occurred.""

 

 

here's my code below

 

libname mylib "D:\File\201812";

data mylib.201812;

 

is there anything wrong with my code?

how can I solve my problem?

 

 

 

andreas_lds
Jade | Level 19

@Kayla_Tan222  i merged your new question with this one to avoid fragmentation of answers. Also please note, that using the word URGENT it not necessary to receive answers and will, most likely not decrease the time you have to wait for an answer.

Kurt_Bremser
Super User

.sas7bdat is the extension of SAS dataset files, so no export is needed, you already have .sas7bdat files anytime you have SAS datasets.

If you want to store your dataset in a certain location, define a library there and use it when you create that dataset:

libname mylib '\\kaiwksgh415thw5\Data\POLA\2018\201812";

data mylib.POLA_clm_mth_201812;
.......
Kayla_Tan222
Calcite | Level 5

Hi KurtBremser,

 

I have tried to run the code below

 

libname mylib "\\kaiwksgh415thw5\Data\POLA\2018\201812";

data mylib.POLA_clm_mth_201812;

 

and a SASdatasets has been saved to the path I set.

However, I unable to open it.

 

It says that The open data operation failed. The following error occurred. An unknown error occurred.

 

How can I solve this?

Kurt_Bremser
Super User

What I gave you was just the beginning of the creation of a dataset, defining a library and a data statement that will start to write a dataset there. Apart form that, all the real code was left intentionally out, as I assumed you have other code that created your dataset, and you need to implement the libname definition and the use of the libname there. The dots I put in are a placeholder for all that.

If the concept of libnames and their use is still strange to you, I highly recommend that you work through the free online Programming 1 course first, where all these basic SAS techniques are taught.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 15 replies
  • 18717 views
  • 0 likes
  • 4 in conversation