BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
niejung
Obsidian | Level 7

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=
1 ACCEPTED SOLUTION

Accepted Solutions
Anand_V
Ammonite | Level 13

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;

View solution in original post

1 REPLY 1
Anand_V
Ammonite | Level 13

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 1 reply
  • 488 views
  • 1 like
  • 2 in conversation