BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi all,


I have a link that looks like this -  https:// ... (year)...(month).xslm. 


The month part of the link changes every month. Is there any way SAS can click, download a file from this URL, and save it to our file system?


I can schedule a job, but I just can't figure out how to make SAS save this file to our file system. I tried PROC HTTP GET request but had no luck. 


Thank you for your help!


Super User
filename _myfile "/home/fkhurshed/downloaded_data%sysfunc(today(), year4.)_%sysfunc(today(), monname3.).xlsm";
proc http method="get" 
 url=", year4.)_%sysfunc(today(), monname3.).xlsm"
filename _myfile clear;

First get this working for a single file with hardcoded dates, something like above. 
Then use %SYSFUNC() with today() and the appropriate format for your date structure to have the date values calculated automatically. 

Meteorite | Level 14

If you want to get a binary copy of the "online" file, do it like this: 


%let year=2023;
%let month=June;

filename in URL "https:// ... (&year.)...(&month.).xslm" 
recfm=N lrecl=1; /* this important for binary copy */

filename out "/path/to/store/the/file/ filename (&year.)...(&month.).xslm" recfm=N lrecl=1;

data _null_;
rc = fcopy("in", "out");
rctxt = sysmsg();
if rc then 
  put "ERROR:" rctxt;

filename in clear;
filename out clear;

I'm using this technique in my programs. 


All the best


Polish SAS Users Group: and

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4 in conversation