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

Hello,

 

I want to import an XLSX file. I'm currently doing it like this:

libname MYLIB XLSX "my_file.xlsx" access=readonly;

 

The problem with this is that I need to rename the variables and send them to the WORk lib.

Is there a way I could import directly to WORK?

I tried chaging the libname parameter but it didn't work...

 

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

You could switch to proc import, but you need one for each sheet, so keeping libname-statement seems to be easier. You can copy datasets using proc copy:

 

proc copy in=mylib out=work;
run;

This step copies all sheets/datasets from mylib to work.

 

For renaming variable proc datasets with modify seem to be the best tool.



 

View solution in original post

3 REPLIES 3
polpel
Fluorite | Level 6

Note that there are two sheets in my excel file

andreas_lds
Jade | Level 19

You could switch to proc import, but you need one for each sheet, so keeping libname-statement seems to be easier. You can copy datasets using proc copy:

 

proc copy in=mylib out=work;
run;

This step copies all sheets/datasets from mylib to work.

 

For renaming variable proc datasets with modify seem to be the best tool.



 

Patrick
Opal | Level 21

@polpel 

As you anyway have to copy the data just use a data step where you can also rename the variables and do whatever other transformations you need. 

Using a SAS data step makes it also really simple to combine the two source sheets into a single table in Work.