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!
filename in "input.txt";
filename out "output.txt";
data _null_;
file in;
input;
put infile_;
datalines4;
GET /index.html HTTP/1.1
;;;;
1
filename in "input.txt";
2
filename out "output.txt";
3
4
DATA _null_;
5
file in;
6
INPUT;
7
put infile_;
8
datalines4;
9
GET /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.
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.