Published on :
Général CREATION_INTERNE

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by defining two external files: 'input.txt' to contain the outgoing HTTP request and 'output.txt' to store the server's response. A DATA STEP (_NULL_) is then used to write the content of the HTTP request (here, a simple GET request for '/index.html') into 'input.txt' using the DATALINES4 directive. Finally, PROC HTTP is invoked with the specified input and output files, as well as the target URL, to execute the request and capture the response.
Data Analysis

Type : CREATION_INTERNE


The data used as the body of the HTTP request (intended for 'input.txt') is created directly within the script via a DATALINES4 block. No existing or unmanaged external SAS data source is used for input. The 'output.txt' file will be generated by the HTTP procedure and will contain the server's response.

1 Code Block
DATA STEP Data
Explanation :
This block defines two file references, 'in' pointing to 'input.txt' and 'out' to 'output.txt'. The 'data _null_' DATA STEP is then used to create the 'input.txt' file and write the content of an HTTP GET request to it. The 'datalines4' directive allows data to be included directly in the SAS code, delimited by lines containing four semicolons (;;;;), ensuring that the entire request, including line breaks, is written to 'input.txt'.
Copied!
1filename in "input.txt";
2filename out "output.txt";
3 
4DATA _null_;
5file in;
6INPUT;
7put infile_;
8datalines4;
9GET /index.html HTTP/1.1
10 
11;;;;
2 Code Block
PROC HTTP
Explanation :
This 'PROC HTTP' procedure is the core of the web interaction. It reads the content of the file designated by 'in' (which is 'input.txt' containing the HTTP request) and sends it to the URL specified by the 'url' option. The server's response is then written to the file designated by 'out' (which is 'output.txt'). The user must replace '<server-name>' with the name or IP address of the target server.
Copied!
1 
2PROC HTTP in=in out=out url="http://<server-name>";
3RUN;
4 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.