BookmarkSubscribeRSS Feed
rahulp
Obsidian | Level 7

Hello,

 

I am stuck in this code for a day and thus far, have been unable to find a solution. My massive companies massive IT and BI teams have been unhelpful. 

 

So I am coming to the community of experts to see if I should just drop the ball and find alternate solution to this.

 

I am not super SAS Smart so please bear with me if I misinterpret something.

 

MIssion: I am trying to connect to either of the 2 links below to get Monthly Data pull for Fed Fund Rate, which would then be used in a much grander SAS Project (Already Developed) as a Multiplier.

 

Here are my links:

 

1.  http://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=d7e27b7b09a3a7feae95b9c61781fc...

 

2. https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv

 

EDIT: Using SAS 9.3 on Linux Server with SAS EG5.1

 

 

Here is my code:

filename in "/server/rahul/Test/in";
filename out "/server/rahul//Test/out.csv";

data _null_;
file in;
input;
put _infile_;
datalines;
;
proc http
out=out
url="https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv"
method="post" proxyhost="xx.xx.xx.x" proxyport=xxxx; run;

When I run this code as is, I get the following error message:

 

ERROR: java.net.ConnectException: Connection refused

 

However, if I remove the "S" from "HTTPS://", I do not get any error message and it generates an output (out.csv) with the following Text within:

 

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv">here</a>.</p>
</body></html>

I have pinged the PROXY with and without Port and it pings fine. Networking is saying that my current SAS (9.3) PROD Server has a connection and firewall exception to connect to the Proxy, however, when I run the "https" code, there is no LOG on the Proxy showing it was hit by SAS PROD Server.

 

Any help would be beneficial. I have googled and tried every single approach mentioned, to no avail.

 

Thanks,

 

RV

 

Note: Same/similar code was posted in the community by a prior ex-consultant, with no solution. This is with more details related to the errors.

11 REPLIES 11
SuryaKiran
Meteorite | Level 14

Did you try using the filename method:

 

Filename want "your path";
Filename data_web url "https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv";

data _null_;
infile data_web;
file want ;
input ;
put _infile_;
;
run;
Thanks,
Suryakiran
rahulp
Obsidian | Level 7

Hi Surya,

 

Thanks for the response. Yes I have. 

 

I get a simple: ERROR: Connection refused.

 

That is why we have a Proxy.

 

Even tried with Proxy: Suffix to filename. Same error.

rahulp
Obsidian | Level 7

Surya, 

Thanks @ChrisHemedinger has done a great job with setting up that resource. I found that this morning and have tried many itteration from their to make my situation work, but no luck. 

 

Still, have bookmarked it for future quick access.

 

I have our SAS team looking at Link One of embedding the Certificate information in the JRE on the server side, and will update. 

 

AlanC
Barite | Level 11

I got this working in C# using the following code. No proxy was used. Hopefully, this will help you find the issue:


        private static void GetRestData()
        {
            string url = "https://www.federalreserve.gov/datadownload/Output.aspx";
            string parms =
                "?rel=H15&series=d7e27b7b09a3a7feae95b9c61781fcd8&lastobs=12&from=&to=&filetype=csv&label=include&layout=seriescolumn&type=csv";
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(url);

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            // List data response.
            HttpResponseMessage response = client.GetAsync(parms).Result;  // Blocking call!
            if (response.IsSuccessStatusCode)
            {
                // Parse the response body. Blocking!
                var json = response.Content.ReadAsStringAsync().Result;
                Console.WriteLine($"{json}");
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }

https://github.com/savian-net
JuanS_OCS
Amethyst | Level 16
Hi there,

i think it would be a good idea to add tge server ssl certificates (of the url) to your sas java private runtime certificate store (with SAS deployment manager). You can ask your SAS admin to do it for you.

Once done, try again with https.
rahulp
Obsidian | Level 7
Juan, I think that is the issue right now. Talked with Networking as http link does hit the Porxy Server, and yields no results, cause well, everything now is https.

However, https does not. I passed on the information Surya posted and I had found earlier to my SAS Admin team and they are looking in to this. I will update this post if that fixes it.
Ksharp
Super User

Or using the third side software like CURL .

rahulp
Obsidian | Level 7

Thanks Ksharp. Will look in to it, but there are major communication breaks between our IT/Networking/SAS Admin team, that i see this being the solution. Still worth checking it out. Thanks.

ChrisHemedinger
Community Manager

On Linux, you definitely need those SSL certificates set up.

 

@AlanC's C# example works on Windows -- seemingly without proxy setup -- because .NET uses the Windows HTTP Client connection and SSL support/proxy routing is handled (usually) through that.

 

@Ksharp suggestion for trying cURL is useful -- but cURL on Linux will have the same requirements for SSL (https) access.  You need the SSL certs.

 

You could try...for fun...via SAS University Edition.  The latest version does have SSL support.  But I don't know how it will work in your proxy setup.  That might be a good proof of concept to help you over the hump and allows you to articulate what you need from your IT folks in a production environment.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
rahulp
Obsidian | Level 7

@ChrisHemedinger You are a genius. One thing I was able to verify is that the Proxy is working the way it should by using SAS University Edition. 

 

I was able to run the following code with no problem and got the output as required and in the format desired.

 

filename out "/folders/myfolders/out.csv";

proc http   
   	out=out 
  	url="http://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=d7e27b7b09a3a7feae95b9c61781fcd8&lastobs=12&from=&to=&filetype=csv&label=include&layout=seriescolumn&type=csv" 
 	method="get"	
 	proxyhost="xx.xx.xx.x"
 	proxyusername= 'patelr'
 	proxypassword= 'xxxxxxxxxxxxx'
	proxyport=xx;

run;

So the proxy works and the code works. It is just the Linux SAS Server is not liking the HTTPS on the Server itself and not even hitting the Proxy. 

 

Our BI (SAS) team has a track open with SAS to figure this out.

 

Will update.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 11 replies
  • 3997 views
  • 7 likes
  • 6 in conversation