SAS and Curl: 'env' in url causes error

后端 未结 2 1330
轻奢々
轻奢々 2021-01-22 09:54

I\'m trying to use CURL with SAS 9.3. I got it working for normal webpages. However, when I try to use it with a URL with \'env\', I get the following error message: \'env\' i

相关标签:
2条回答
  • 2021-01-22 10:54

    Yes I've hit this issue before and it took a while to figure out.

    It turns out that you need to use a caret ^ to mask any ampsersand & characters whenever you process it through the command line pipe. Looking back at it now I have no idea how I figured it out...

    Also - you need to use a lowercase -k I believe.

    I cleaned it up a little and this worked fine for me:

    %let query= %sysfunc(urlencode(SELECT * FROM yahoo.finance.option_contract WHERE symbol='YHOO'));
    %let env  = %sysfunc(urlencode(store://datatables.org/alltableswithkeys));
    %let url  = https://query.yahooapis.com/v1/public/yql?q=&query^%nrstr(&)diagnostics=true^%nrstr(&)env=&env;
    
    filename curl pipe "d:\sasdev\common\bin\curl\curl.exe -k &url 2>&1";
    
    data _null_;
      infile curl lrecl=32767;
      input;
      put _infile_;
    run;
    

    Note that you'll want to change the path to curl.

    0 讨论(0)
  • 2021-01-22 10:54

    I would try adding quotes that will get passed to Windows.

    Something like

    "curl -k ""&url."" 2>&1"
    

    The doubled double quotes are passesd as a single " character to Windows.

    0 讨论(0)
提交回复
热议问题