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
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.
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.