Bruno:
Thanks but I get a Syntax Error using (my mod) of your code:
%macro get_examples(period,country,product);
%let time = .
%let cty_code = &country;
%let I_commodity = &product*;
filename resp temp;
proc http
method="get"
url='https://api.census.gov/data/timeseries/intltrade/imports/hs'
query=(
"get" = "YEAR,MONTH,RP,CTY_CODE,CTY_SUBCODE,DISTRICT,DIST_NAME,CON_QY1_MO,CON_QY1_YR,I_COMMODITY,I_COMMODITY_SDESC,I_COMMODITY_LDESC,CON_VAL_MO,CON_VAL_YR,CON_CHA_MO,CON_CHA_YR,GEN_VAL_MO,CAL_DUT_MO,CAL_DUT_YR"
"SUMMARY_LVL2" = "HSCYCSDTRP"
"COMM_LVL" = "HS10"
"time"="&time"
"CTY_CODE" = "&CTY_CODE"
"I_COMMODITY" = "&I_COMMODITY"
)
verbose
out=resp
;
run;
libname resp json;
proc copy in=resp out=work;
run;
libname resp clear;
filename resp clear;
proc append force base=impdetl2 data=ROOT;
run;
%mend get_examples;
%get_examples(2021-11,*,0101)
%get_examples(2021-11,*,0102)
44 %get_examples(2021-11,*,0101)
NOTE: Line generated by the invoked macro "GET_EXAMPLES".
1 proc http method="get" url='https://api.census.gov/data/timeseries/intltrade/imports/hs'
1 ! query=( "get" =
-----
22
WARNING: Apparent symbolic reference KEY not resolved.
NOTE: Line generated by the invoked macro "GET_EXAMPLES".
1 filename resp temp; proc http method="get" url='https://api.census.gov/data/timeseries/intltrade/imports/hs'
1 ! query=( "get" =
-----
76
ERROR 22-322: Syntax error, expecting one of the following: ;, AUTH_ANY, AUTH_BASIC, AUTH_NEGOTIATE, AUTH_NONE, AUTH_NTLM,
CLEAR_CACHE, CLEAR_CONN_CACHE, CLEAR_COOKIES, CT, EXPECT_100_CONTINUE, FOLLOWLOC, HEADERIN, HEADEROUT,
HEADEROUT_OVERWRITE, HTTP_TOKENAUTH, IN, METHOD, NOFOLLOW, NOFOLLOWLOC, NO_CONN_CACHE, NO_COOKIES, OAUTH_BEARER,
OUT, PASSWORD, PROXYHOST, PROXYPASSWORD, PROXYPORT, PROXYUSERNAME, PROXY_AUTH_BASIC, PROXY_AUTH_NEGOTIATE,
PROXY_AUTH_NONE, PROXY_AUTH_NTLM, TIMEOUT, URL, USERNAME, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME.
ERROR 76-322: Syntax error, statement will be ignored.
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
NOTE: The SAS System stopped processing this step because of errors.
NOTE: JSON data is only read once. To read the JSON again, reassign the JSON LIBNAME.
ERROR: Physical file does not exist, e:\SAS Temporary Files\_TD19132_DESKTOP-575EP3T_\#LN00054.
ERROR: Error in the LIBNAME statement.
ERROR: Libref RESP is not assigned.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE COPY used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
NOTE: The SAS System stopped processing this step because of errors.
WARNING: Libref RESP is not assigned.
NOTE: Fileref RESP has been deassigned.
ERROR: File WORK.ROOT.DATA does not exist.
NOTE: Statements not processed because of errors noted above.
NOTE: The data set WORK.IMPDETL2 has 0 observations and 0 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
NOTE: The SAS System stopped processing this step because of errors.
... View more