<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAS to Download File from Dynamic URL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882952#M348876</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _myfile "/home/fkhurshed/downloaded_data%sysfunc(today(), year4.)_%sysfunc(today(), monname3.).xlsm";
 
proc http method="get" 
 url="https://www.noaa.gov........%sysfunc(today(), year4.)_%sysfunc(today(), monname3.).xlsm"
 out=_myfile
;
run;
 
filename _myfile clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First get this working for a single file with hardcoded dates, something like above.&amp;nbsp;&lt;BR /&gt;Then use %SYSFUNC() with today() and the appropriate format for your date structure to have the date values calculated automatically.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 15:07:34 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-06-29T15:07:34Z</dc:date>
    <item>
      <title>SAS to Download File from Dynamic URL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882884#M348842</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a link that looks like this -&amp;nbsp; https:// ... (year)...(month).xslm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 01:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882884#M348842</guid>
      <dc:creator>dkewon</dc:creator>
      <dc:date>2023-06-29T01:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Download File from Dynamic URL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882903#M348851</link>
      <description>Have a look at this post: &lt;A href="https://blogs.sas.com/content/sasdummy/2017/12/04/scrape-web-page-data/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2017/12/04/scrape-web-page-data/&lt;/A&gt;</description>
      <pubDate>Thu, 29 Jun 2023 09:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882903#M348851</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-06-29T09:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Download File from Dynamic URL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882952#M348876</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _myfile "/home/fkhurshed/downloaded_data%sysfunc(today(), year4.)_%sysfunc(today(), monname3.).xlsm";
 
proc http method="get" 
 url="https://www.noaa.gov........%sysfunc(today(), year4.)_%sysfunc(today(), monname3.).xlsm"
 out=_myfile
;
run;
 
filename _myfile clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First get this working for a single file with hardcoded dates, something like above.&amp;nbsp;&lt;BR /&gt;Then use %SYSFUNC() with today() and the appropriate format for your date structure to have the date values calculated automatically.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882952#M348876</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-29T15:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Download File from Dynamic URL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882964#M348884</link>
      <description>&lt;P&gt;If you want to get a binary copy of the "online" file, do it like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year=2023;
%let month=June;


filename in URL "https:// ... (&amp;amp;year.)...(&amp;amp;month.).xslm" 
recfm=N lrecl=1; /* this important for binary copy */

filename out "/path/to/store/the/file/ filename (&amp;amp;year.)...(&amp;amp;month.).xslm" recfm=N lrecl=1;

data _null_;
rc = fcopy("in", "out");
rctxt = sysmsg();
if rc then 
  put "ERROR:" rctxt;
run;

filename in clear;
filename out clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm using this technique in my programs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-to-Download-File-from-Dynamic-URL/m-p/882964#M348884</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-06-29T15:33:01Z</dc:date>
    </item>
  </channel>
</rss>

