09-01-2017 05:56 PM
Looking for some help. This is my first attempt to pull data using an API. In the past I go out and download the U.S. Census American Community Survey files I need as CSV's and do a PROC IMPORT. I'd like to try and get only the few variables I need via their API.
This is my code to get totals for all census tracts (1249) in my state:
filename test "C:\Users\n00b\Desktop\API_Test\test.txt";
method = 'GET'
I pull it into a text file but it generates the following green text
WARNING: Apparent symbolic reference FOR not resolved. WARNING: Apparent symbolic reference IN not resolved. WARNING: Apparent symbolic reference IN not resolved.
I'm assuming because I have wildcards to get all the different tracts?
Also now that I have the API data, how do I get it into a SAS dataset format? Is there a way besides PROC IMPORT?
Can I ask for multiple variables from different tables on the same call or is it one request per line (e.g. Var 1 on Table A and Var 1 on Table B in the same line of code)?
Sorry this is probably basic stuff but I'm getting stuck. Any help appreciated!
09-01-2017 07:13 PM
The warning messages happen because SAS is interpreting the URL text &XXX as a reference to a macro variable you have not previously defined. Enclosing your URL string in single quotes rather that double quotes should remove the warnings.
As for reading in the text file, you could do that in a DATA step using an INFILE and an INPUT statement similar to:
data test; infile test; input column1 $ column2 $ column3 $; run;
You can change the INPUT statement to match the layout of your text file. Please supply details of the layout if you need further help.