BookmarkSubscribeRSS Feed
Assaf_Attas
Obsidian | Level 7

hey guys,

 

i'm trying to automate a download process using SAS.

i found some posts on this but non of them worked for me..

 

the code runs but i dont get the expected resault

 

any help?

method 1

filename out "%sysfunc(getoption(WORK))\DL_File.xlsx";
 
proc http
 url='https://data.gov.il/dataset/branches/resource/1c5bc716-8210-4ec7-85be-92e6271955c2/download/snifim_heboi.org.il.xlsx'
 method="get" out=out;
run;

method2

filename myinfile url "https://data.gov.il/dataset/branches/resource/1c5bc716-8210-4ec7-85be-92e6271955c2/download/snifim_heboi.org.il.xlsx";
filename out "%sysfunc(getoption(WORK))\DL_File.xlsx";

data _null_;
	n=-1;
	infile myinfile recfm=s nbyte=n length=len;
	file out recfm=n;

	input;
	put _infile_ $varying32767. len;

run;
4 REPLIES 4
Kurt_Bremser
Super User

Run your first code with a different outfile name:

filename out "/folders/myfolders/DL_File.html";

and you will find that you do not get a XLSX file, but a HTML file with lots of scripts in the header and no body.

Assaf_Attas
Obsidian | Level 7
that's what i referred as the undesired result.
what i need is the actual file the link refers to.
Kurt_Bremser
Super User

The problem here seems to be this:

Instead of supplying the file, the website sends a script which then does the download. Since PROC HTTP is not a full-fledged web browser with a Javascript sandbox, this won't work.

IMO, the non-standard way that the website handles downloads means that you can't automate this in SAS, but I may be proven otherwise.

I suggest that you also open a track with SAS technical support while you wait for possible answers here.

EyalGonen
Lapis Lazuli | Level 10

Hi @Assaf_Attas ,

 

I tested your URL with a 3rd party tool called "curl" and I got back from the server a file that contains HTML with embedded JavaScript as @Kurt_Bremser suggested.

So it seems like this is not a SAS specific problem with handling this URL as it seems like "curl" is not downloading the XLSX file as well.

 

Cheers,

Eyal

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 4 replies
  • 1584 views
  • 0 likes
  • 3 in conversation