Hi everyone,
Could anyone please help me with a code that will allow the user to brow to the location of an excel file to import to SAS?
I am using SAS 9.4 Base (not EG)
Thank you
Kind regards
AM
If you're going to need prompts I would suggest switching to SAS EG or Studio or AddIn for Microsoft Office.
Otherwise you're stuck rolling your own via JavaScript or another application interface. SAS Base is not designed for interactive solutions like this.
Usually, if it's base I have parameters at the top and people have to copy/paste in the path. To import all sheets, you can use the XLSX libname approach and PROC COPY. This should copy all the sheets with data to the WORK library.
%let pathFileImport = C:\_localdata\temp\Demo.xlsx;
libname demo xlsx "&pathFileImport";
proc copy in=demo out=work;
run;
Hi:
If you are already using Base SAS 9.4, the Windowing Environment has an Import Data menu option that allows you to browse to the location of a file to import: File --> Import Data --> and then follow the prompts in the Import Window:
Hope this helps,
Cynthia
Thanks Cynthia
I am aware of the import functionality through the drop-down menu, I was however looking for achieving something similar using the code itself.
I have looked into %window but not sure I can get a pop up menu with a browse button to allow the user to choose the path of the excel file.
The issue is that the excel file will contain multiple sheets, so i was trying to capture the file path through a prompt to the user, then use proc import to import all the sheets from the excel file
Thanks again
AM
Hi:
I do not believe that %WINDOW will allow you to implement a browse button, because the browse button would have to go out to the operating system and then return the results to the %WINDOW program. This is probably a question for Tech Support. I don't actually recommend using %WINDOW because it has limited usefulness in a client/server scenario. You might try investigating SAS Studio, you can build your own tasks and, in fact, there is an Import Task that you might even be able to start with as a model. It was my understanding that SAS Studio was available with Base 9.4 -- when I installed the latest version of SAS 9.4, I got all 3 interfaces: SAS on Windows, SAS EG and SAS Studio. Here's what the Import Task looks like in SAS Studio:
Cynthia
If you're going to need prompts I would suggest switching to SAS EG or Studio or AddIn for Microsoft Office.
Otherwise you're stuck rolling your own via JavaScript or another application interface. SAS Base is not designed for interactive solutions like this.
Usually, if it's base I have parameters at the top and people have to copy/paste in the path. To import all sheets, you can use the XLSX libname approach and PROC COPY. This should copy all the sheets with data to the WORK library.
%let pathFileImport = C:\_localdata\temp\Demo.xlsx;
libname demo xlsx "&pathFileImport";
proc copy in=demo out=work;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.