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.

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 832 views
  • 0 likes
  • 3 in conversation