Hello again, Thank you for replying. Again, I came into this issue with very little idea of what an API is or how to access it, but my understanding is a bit closer now. Through some combination of trial and error based on your suggestions, I put together the following snippets that worked. /* This snippet: */ /* subsets the long list of VINs into manageable chunks for the API; */ /* (create the subset by picking row numbers of the dataset, i.e., row 1 - row 50) */ /* creates the API call for each VIN; */ /* and, converts the dataframe field into a list */ %macro run_VINs(startobs, endobs);
data VINSubset (where = (row_num >= &startobs & row_num <= &endobs));
set unique_VINs;
VINforAPI = cats("https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVinValues/",ShortVIN,"?format=csv");
row_num = _N_;
keep ShortVIN row_num VINforAPI;
run;
proc sql
noprint;
select
VINforAPI
into :VINList separated by '|'
from VINSubset;
quit;
%mend; /* This snippet: */ /* iterates through each API call in the list */ /* it pulls out the VIN from the call and uses that substring to make an output file */ /* it runs each API call through the API and writes the results to the output file */ /* finally, it imports the output file into SAS for further processing */ %macro decodeVIN(list);
%do i = 1 %to %sysfunc(countw(&list.,|));
%let VIN = %scan(&list., &i, |);
%let output = path\to\my\output\VIN_%substr(&VIN, 57, 9).csv;
filename V&i "&output";
proc http
method = "GET"
url = "&VIN"
out = V&i;
run;
proc import
out = work._VIN&i
datafile = "path\to\my\output\VIN_%substr(&VIN, 57, 9).csv"
dbms = csv REPLACE;
getnames = yes;
run;
%mend;
... View more