DATA Step, Macro, Functions and more

Making macro variables resolve with filename pipe command, with single and double quotes

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Making macro variables resolve with filename pipe command, with single and double quotes

Piping a cURL command, I can get the macro variable &array to resolve but I need to make the (-d ID) a macro variable and cannot get it to work.

SAS 9.4.4

 

This works:

%LET array = 192.160.1.10

filename curl5 pipe %TSLIT(curl  -L --location-trusted -sk https://&array.:4443/object /info?include_bucket_detail=true -d '{ "id" : ["tst-01"] }' -b /apps/ITNSM/ecs/cookie/Kookie_&array -H "Content-Type: application/json" -H "Accept: application/json")      ;

 

Sample of what I need to get working.

This does not work:  I need to have the &ID resolve the macro variable.  I have tried many variation of using %str/%quote/%bquote but I do not have a good understanding of making this successful.

%LET array = 192.160.1.10

%LET ID= tst-01

 

filename curl5 pipe %TSLIT(curl  -L --location-trusted -sk https://&array.:4443/ object /info?include_bucket_detail=true true -d '{ "id" : ["&ID"] }' -b /apps/ITNSM/ecs/cookie/Kookie_&array -H "Content-Type: application/json" -H "Accept: application/json")      ;

 

Here is the syntax for the working cURL command under Linux:  (Cookie collection is missing), The -d with single and double quotes is the requirement that is giving me trouble.

 

curl "https:// 192.160.1.10:4443/object/ object /info?include_bucket_detail=true true" -d '{"id" : ["tst-01"] }'  \

 -b  /cookie/Kookie_192.160.1.10 -k -v   \

 -H "Content-Type: application/json" \

 -H "accept: application/json"

 

 


Accepted Solutions
Solution
‎02-14-2018 07:51 AM
Super User
Posts: 6,644

Re: Making macro variables resolve with filename pipe command, with single and double quotes

Assuming you have added semicolons ending your %LET statements ...

 

Take this part:

 

'{ "id" : ["&ID"] }'

 

Replace it with:

 

%unquote(%str(%'{ "id" : ["&ID"] }%' ))

 

%STR will temporarily remove the impact of the quotes (which have been suppressing resolution of &ID), and then %UNQUOTE will restore those quotes after resolution has taken place.

View solution in original post


All Replies
Solution
‎02-14-2018 07:51 AM
Super User
Posts: 6,644

Re: Making macro variables resolve with filename pipe command, with single and double quotes

Assuming you have added semicolons ending your %LET statements ...

 

Take this part:

 

'{ "id" : ["&ID"] }'

 

Replace it with:

 

%unquote(%str(%'{ "id" : ["&ID"] }%' ))

 

%STR will temporarily remove the impact of the quotes (which have been suppressing resolution of &ID), and then %UNQUOTE will restore those quotes after resolution has taken place.

New Contributor
Posts: 2

Re: Making macro variables resolve with filename pipe command, with single and double quotes

Posted in reply to Astounding

Your solution works!...thanks for your help.  I think I have a better understanding of how you used the combination of %str and %unquote to get the macro variable to resolve.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 131 views
  • 1 like
  • 2 in conversation