I am having to difficulty to display code and message in the log. I plan to use that code and tell SAS program to return code = 2 when the code <> 200
How can I fix?
Code:
 proc http
      url=%UNQUOTE(%STR(%'&valueURL%'))
      method="POST"
       in=jason_in
      out=myout
      headerout=out;
      headers "host"=%UNQUOTE(%STR(%'&valueHost%')) "content-type"=%UNQUOTE(%STR(%'&valueType%')) "Authorization"="Basic %UNQUOTE(%STR(&basevalue))";
   run;
   data _null_;
       infile out;
      input;
      put _infile_;
   run;
   data _null_; 
           infile out scanover truncover; 
           input @'HTTP/1.1' code 4. message $255.; 
           call symputx('status_code',code,'g'); 
           call symputx('status_message',trim(message),'g'); 
        %put status_code=;
           %put status_message=;
   run;Log:
 MACROGEN(CALL_REST_SVC):   data _null_;
MACROGEN(CALL_REST_SVC):   infile out;
MACROGEN(CALL_REST_SVC):   input;
MACROGEN(CALL_REST_SVC):   put _infile_;
MACROGEN(CALL_REST_SVC):   run;
HTTP/1.1 403
Set-Cookie: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Path=/; Secure; HttpOnly
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sat, 10 Oct 2020 04:58:13 GMT
Set-Cookie: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc; path=/; HttpOnly; Secure
MACROGEN(CALL_REST_SVC):   data _null_;
MACROGEN(CALL_REST_SVC):   infile out scanover truncover;
MACROGEN(CALL_REST_SVC):   input @'HTTP/1.1 ' code 4. message $255.;
MACROGEN(CALL_REST_SVC):   call symputx('status_code',code,'g');
MACROGEN(CALL_REST_SVC):   call symputx('status_message',trim(message),'g');
status_code=
status_message=
filename resp TEMP;
filename headers TEMP;
proc http method="GET" url="http://www.google.com" 
		headerout=headers out=resp 
		HEADEROUT_OVERWRITE;
run;
   data _null_;
       infile headers;
      input;
      put _infile_;
   run;
   
    
   data _null_; 
           infile headers scanover truncover; 
           input @'HTTP/1.1' code 4. message $255.; 
           call symputx('status_code',code,'g'); 
           call symputx('status_message',trim(message),'g'); 
        %put status_code=&status_code;
           %put status_message=&status_message;
           run;Log:
       data _null_;
 90                    infile headers scanover truncover;
 91                    input @'HTTP/1.1' code 4. message $255.;
 92                    call symputx('status_code',code,'g');
 93                    call symputx('status_message',trim(message),'g');
 94                 %put status_code=&status_code;
 status_code=200
 95                    %put status_message=&status_message;
 status_message=OK
 96                    run;
filename resp TEMP;
filename headers TEMP;
proc http method="GET" url="http://www.google.com" 
		headerout=headers out=resp 
		HEADEROUT_OVERWRITE;
run;
   data _null_;
       infile headers;
      input;
      put _infile_;
   run;
   
    
   data _null_; 
           infile headers scanover truncover; 
           input @'HTTP/1.1' code 4. message $255.; 
           call symputx('status_code',code,'g'); 
           call symputx('status_message',trim(message),'g'); 
        %put status_code=&status_code;
           %put status_message=&status_message;
           run;Log:
       data _null_;
 90                    infile headers scanover truncover;
 91                    input @'HTTP/1.1' code 4. message $255.;
 92                    call symputx('status_code',code,'g');
 93                    call symputx('status_message',trim(message),'g');
 94                 %put status_code=&status_code;
 status_code=200
 95                    %put status_message=&status_message;
 status_message=OK
 96                    run;It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.
